<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title data-lang="title">Log in to your Emokili Account</title>
    <meta name="description"
          content="Emokili is the leading Wi-Fi Cloud Digital Frame, a global provider. Share photos of your memorable experiences with our best digital photo frames.">
    <link rel="shortcut icon" href="../static/images/b2c-login/favicon.ico">
    <style>
        html {
            width: 100%;
            height: 100%
        }

        body, html {
            padding: 0;
            margin: 0;
            font-size: 16.5px
        }

        body, html, input {
            font-family: avenirlight, 'Avenir W01', Avenir, Helvetica, Arial, sans-serif
        }

        * {
            box-sizing: border-box
        }

        .flex-1 {
            -webkit-box-flex: 1;
            -moz-box-flex: 1;
            width: 20%;
            -webkit-flex: 1;
            -ms-flex: 1;
            flex: 1
        }

        .flex {
            display: -webkit-box;
            display: -moz-box;
            display: -ms-flexbox;
            display: -webkit-flex;
            display: flex
        }

        .container {
            padding: 0 15px;
            width: 100%;
            max-width: 480px;
            margin: 0 auto
        }

        .input-group {
            overflow: hidden
        }

        .input-group.padding {
            padding: 8px
        }

        .input-group input {
            outline: 0
        }

        .input-group input, button {
            font-size: 1em;
            border: none
        }

        .input-group.border {
            border: solid 1px silver;
            border-radius: 5px
        }

        .input-group.focus {
            border: solid 1px #000
        }

        .input-group.red {
            border: solid 1px red
        }

        .btn {
            border-radius: 5px
        }

        .full-height {
            min-height: 70vh
        }

        .btn-full {
            width: 100%
        }

        .bg-blue {
            background: #479ade
        }

        .bg-white {
            background: #fff
        }

        .bg-trasparent {
            background: 0 0
        }

        .color-blue {
            color: #479ade
        }

        .color-white {
            color: #fff
        }

        a {
            text-decoration: none !important
        }

        .block {
            display: block
        }

        .inline-block {
            display: inline-block
        }

        .padding-y-20 {
            padding-top: 20px;
            padding-bottom: 20px
        }

        .padding-x-20 {
            padding-left: 20px;
            padding-right: 20px
        }

        .padding-y-8 {
            padding-top: 8px;
            padding-bottom: 8px
        }

        .padding-20 {
            padding: 20px
        }

        .padding-top-20 {
            padding-top: 20px
        }

        .padding-14 {
            padding: 14px
        }

        .cursor-pointer {
            cursor: pointer
        }

        .margin-right-20 {
            margin-right: 20px
        }

        .margin-x-20 {
            margin-left: 20px;
            margin-right: 20px
        }

        .margin-y-40 {
            margin-top: 40px;
            margin-bottom: 40px
        }

        .margin-top-20 {
            margin-top: 20px
        }

        .margin-left-20 {
            margin-left: 20px
        }

        .margin-right-20 {
            margin-right: 20px
        }

        .margin-bottom-40 {
            margin-bottom: 40px
        }

        .margin-top-40 {
            margin-top: 40px
        }

        .no-margin-top {
            margin-top: 0
        }

        .no-margin-bottom {
            margin-bottom: 0
        }

        .header {
            background: #f8f8f8
        }

        .text-center {
            text-align: center
        }

        .header img {
            height: 50px;
            max-width: 200px
        }

        .font-normal {
            font-weight: 400
        }

        body {
            background-image: url(../static/images/b2c-login/nixPattern.jpg);
            background-repeat: repeat-x;
            background-size: 100% auto;
            background-position: left bottom;
            background-attachment: fixed;
        }

        .items-center {
            align-items: center
        }

        .store-images img {
            height: 50px;
            width: 167px;
        }

        .icon {
            height: 25px
        }

        .color-red {
            color: red
        }

        ul, li {
            margin: 0px;
            padding: 0px;
        }

        li {
            list-style: none;
        }

        .input-group {
            padding: 1px;
        }

        .input-group.border.error {
            border: solid 1px red;
        }

        .input-group.error {
            position: relative;
            overflow: visible;
        }

        .input-group.error input {
            border-radius: 5px;
        }

        .margin-y-20 {
            margin-top: 20px;
            margin-bottom: 20px;
        }

        .input-error {
            display: none
        }

        .input-group.error .input-error {
            top: 106%;
            left: 0px;
            position: absolute;
            color: red;
            display: block;
            width: 100%;
            max-width: 100%;
            line-height: 100%;
        }

        .input-error span {
            font-size: 90%;
        }

        .auth-modal-signup-1, .auth-modal-signup-2, .auth-modal-signup-3, .app-section {
            display: none;
        }

        .signup-1 .auth-modal-signup-1, .signup-1 .app-section {
            display: block;
        }

        .signup-2 .auth-modal-signup-2 {
            display: block;
        }

        .signup-3 .auth-modal-signup-3 {
            display: block;
        }

        .hide {
            display: none;
        }

        .ui-autocomplete {
            max-height: 400px;
            overflow-y: scroll;

        }

        .ui-autocomplete .ui-menu-item {
            padding: 20px;
        }

        .form-radio {
            -webkit-appearance: none;
            -moz-appearance: none;
            appearance: none;
            display: inline-block;
            position: relative;
            background-color: #f1f1f1;
            color: #666;
            top: 8px;
            height: 20px;
            width: 20px;
            border: 0;
            border-radius: 50px;
            cursor: pointer;
            margin-right: 3px;
            outline: none;
        }

        .form-radio:checked::before {
            position: absolute;
            font: 13px/1 'Open Sans', sans-serif;
            left: 6px;
            top: 3px;
            content: '\02143';
            transform: rotate(40deg);
        }

        .form-radio:after {
            content: ' ';
            position: absolute;
            top: -2px;
            left: -2px;
            border-radius: 50px;
            height: 20px;
            width: 20px;
            border: solid 2px grey;
        }

        .form-radio:hover {
            background-color: #f7f7f7;
        }

        .form-radio:checked {
            background-color: #f1f1f1;
        }

        label {
            font: 15px/1.7 'Open Sans', sans-serif;
            color: #333;
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            cursor: pointer;
        }
    </style>

    <script type="text/javascript">
        var env = 'prod';
        var apiUrl = 'http://127.0.0.1:8002'; // 'http://api.devm.emokili.com'
        var wwwUrl = 'https://www.emokili.com';
        var apiV3Url = 'https://api.emokili.com/v3'; // 'http://api.devm.emokili.com/v3'
        var usernameDomainPart = 'myemokili.com';
    </script>

    <script>
        !function (e) {
            var n = !1;
            if ("function" == typeof define && define.amd && (define(e), n = !0), "object" == typeof exports && (module.exports = e(), n = !0), !n) {
                var o = window.Cookies, t = window.Cookies = e();
                t.noConflict = function () {
                    return window.Cookies = o, t
                }
            }
        }(function () {
            function g() {
                for (var e = 0, n = {}; e < arguments.length; e++) {
                    var o = arguments[e];
                    for (var t in o) n[t] = o[t]
                }
                return n
            }

            return function e(l) {
                function C(e, n, o) {
                    var t;
                    if ("undefined" != typeof document) {
                        if (1 < arguments.length) {
                            if ("number" == typeof (o = g({path: "/"}, C.defaults, o)).expires) {
                                var r = new Date;
                                r.setMilliseconds(r.getMilliseconds() + 864e5 * o.expires), o.expires = r
                            }
                            o.expires = o.expires ? o.expires.toUTCString() : "";
                            try {
                                t = JSON.stringify(n), /^[\{\[]/.test(t) && (n = t)
                            } catch (e) {
                            }
                            n = l.write ? l.write(n, e) : encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent), e = (e = (e = encodeURIComponent(String(e))).replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent)).replace(/[\(\)]/g, escape);
                            var i = "";
                            for (var c in o) o[c] && (i += "; " + c, !0 !== o[c] && (i += "=" + o[c]));
                            return document.cookie = e + "=" + n + i
                        }
                        e || (t = {});
                        for (var a = document.cookie ? document.cookie.split("; ") : [], s = /(%[0-9A-Z]{2})+/g, f = 0; f < a.length; f++) {
                            var p = a[f].split("="), d = p.slice(1).join("=");
                            this.json || '"' !== d.charAt(0) || (d = d.slice(1, -1));
                            try {
                                var u = p[0].replace(s, decodeURIComponent);
                                if (d = l.read ? l.read(d, u) : l(d, u) || d.replace(s, decodeURIComponent), this.json) try {
                                    d = JSON.parse(d)
                                } catch (e) {
                                }
                                if (e === u) {
                                    t = d;
                                    break
                                }
                                e || (t[u] = d)
                            } catch (e) {
                            }
                        }
                        return t
                    }
                }

                return (C.set = C).get = function (e) {
                    return C.call(C, e)
                }, C.getJSON = function () {
                    return C.apply({json: !0}, [].slice.call(arguments))
                }, C.defaults = {}, C.remove = function (e, n) {
                    C(e, "", g(n, {expires: -1}))
                }, C.withConverter = e, C
            }(function () {
            })
        });
    </script>
    <script>
        window.addEventListener("pageshow", function (event) {
            var historyTraversal = event.persisted ||
                (typeof window.performance != "undefined" &&
                    window.performance.navigation.type === 2);
            if (historyTraversal) {
                // Handle page restore.
                window.location.reload();
            }
        });
        (function () {
            'use strict';
            var loginTokenIdKey = env + '.token.id';
            var loginToken = 'emokili.token';
            var tokenId = Cookies.get(loginTokenIdKey);
            var currentToken = window.localStorage.getItem(loginToken) || window.sessionStorage.getItem(loginToken);

            function validate(data) {
                if ((!data.signage && currentToken)) {
                    location.replace('/');
                }
            }

            if (tokenId) {
                var oReq = new XMLHttpRequest();
                oReq.onreadystatechange = function () {
                    if (this.readyState == 4 && this.status == 200) {
                        var data = JSON.parse(this.responseText);
                        validate(data);
                    }
                };
                oReq.open("POST", apiUrl + '/www-token-id-check/', true);
                oReq.send('tokenId=' + tokenId);
            }
        })();
    </script>
    <script>
        var USER_LANGUAGE = {
            'en_US': {
                'title': 'Log in to Emokili',
                'username': 'Username / Email',
                'password': 'Password',
                'remember': 'Remember me',
                'password_form': 'Password Reminder Form',
                'login': 'Login',
                'forgot': 'Forgot your password?',
                'new_to_emokili': 'New to Emokili?',
                'create_account': 'Create an Account',
                'download_app': 'Download Emokili Mobile App',
                'all_rights': '© 2020 Emokili. All rights reserved.',
                'app_store': './images/b2c-login/app-store-2x.png',
                'google_play': './images/b2c-login/play-store-2x.png'
            },
            'de_DE': {
                'title': 'Bei Emokili anmelden',
                'username': 'Benutzername / Email',
                'password': 'Passwort',
                'remember': 'Meine angegebenen Daten speichern',
                'password_form': 'Formular zur Passworterinnerung',
                'login': 'Anmelden',
                'forgot': 'Haben Sie Ihr Passwort vergessen?',
                'new_to_emokili': 'Neuer Emokili Nutzer?',
                'create_account': 'Konto erstellen',
                'download_app': 'Emokili Mobile App herunterladen',
                'all_rights': '© 2020 Emokili. Alle Rechte. Reserviert.',
                'app_store': '/images/b2c-login/app-store-de.svg',
                'google_play': '/images/b2c-login/play-store-de.svg'
            },
            'ja_JP': {
                "title": "Emokiliへのログイン",
                "username": "ユーザー名／電子メール",
                "password": "パスワード",
                "remember": "次から入力を省略",
                "password_form": "パスワードリマインダ用紙",
                "login": "ログイン",
                "forgot": "パスワードをお忘れですか？",
                "new_to_emokili": "Emokiliは初めてですか？",
                "create_account": "アカウント作成",
                "download_app": "Emokiliモバイルアプリダウンロード",
                "all_rights": "© 2020 Emokili.無断複写・複製・転載を禁ず。",
                'app_store': '/images/b2c-login/app-store-jp.svg',
                'google_play': '/images/b2c-login/play-store-jp.png'
            },
            'fr_FR': {
                "title": "Se connecter à Emokili",
                "username": "Nom d'utilisateur / Adresse e-mail",
                "password": "Mot de passe",
                "remember": "Se souvenir de moi",
                "password_form": "Rappel de mot de passe",
                "login": "Se connecter",
                "forgot": "Mot de passe oublié ?",
                "new_to_emokili": "Nouveau sur Emokili ?",
                "create_account": "Créer un compte",
                "download_app": "Télécharger l'application mobile Emokili",
                'all_rights': '© 2020 Emokili. Tous droits réservés.',
                'app_store': '/images/b2c-login/app-store-fr.svg',
                'google_play': '/images/b2c-login/play-store-fr.png',
            },
        }
    </script>

</head>
<body>
<div class="header padding-y-20 text-center margin-bottom-40">
    <img src="../static/images/b2c-login/Emokili Logo Horizontal Lockup RGB v3 all.svg" alt="">
    <style>
        #lang-picker {
            display: inline-block;
            position: absolute;
            right: 10vw;
            width: 150px;
            height: 50px;
            cursor: pointer;
            opacity: 0;
            transition: opacity 0.3s 1s ease-out;
        }

        #lang-picker-btn {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 50px;
            color: #555;
        }

        #lang-picker-btn span {
            margin: 0 8px;
        }

        #lang-picker:hover #lang-picker-dropdown {
            display: flex;
        }

        #lang-picker-dropdown {
            display: none;
            justify-content: center;
            align-items: center;
            flex-wrap: wrap;
            width: 150px;
            border: 1px solid #ddd;
            border-radius: 5px;
            background: white;
            box-shadow: 0px 6px 8px -4px #ddd;
        }

        #lang-picker-dropdown a {
            width: 150px;
            padding: 20px;
            border-bottom: 1px solid #ddd;
            color: #bbb;
            transition: color 0.3s ease-out;
        }

        #lang-picker-dropdown a:hover {
            color: #000;
        }

        @media all and (max-width: 600px) {
            #lang-picker {
                display: block;
                position: relative;
                right: unset;
                margin: auto;
            }
        }
    </style>
    <div id="lang-picker">
        <div id="lang-picker-btn">
            <ion-icon style="font-size: 30px;" name="globe-outline"></ion-icon>
            <span id="lang-picker-btn-value"></span>
            <ion-icon name="chevron-down-outline"></ion-icon>
        </div>
        <div id="lang-picker-dropdown">
            <a onclick="changeLang('en_US')">English</a>
            <a onclick="changeLang('de_DE')">Deutsch</a>
            <a onclick="changeLang('fr_FR')">Français</a>
            <a onclick="changeLang('ja_JP')">日本語</a>
        </div>
    </div>
    <script type="module" src="https://unpkg.com/ionicons@5.0.0/dist/ionicons/ionicons.esm.js"></script>
    <script nomodule="" src="https://unpkg.com/ionicons@5.0.0/dist/ionicons/ionicons.js"></script>
    <script>
        function getSystemFeature() {
            if (env === 'dev') {
                env = 'rnd'
            }
            return fetch(`https://api.${env === 'prod' ? '' : env + '.'}emokili.com/v3/system-features`).then(data => data.json()).then(({features}) => {
                return features.map(x => x.name)
            }).catch(e => {
                return []
            })
        }

        function getCookieValue(a) {
            var b = document.cookie.match('(^|[^;]+)\\s*' + a + '\\s*=\\s*([^;]+)');
            return b ? b.pop() : '';
        }

        function init() {
            var lang = getCookieValue('lang')
            console.log(lang)
            getSystemFeature()
                .then(features => {
                    var $lang = document.getElementById('lang-picker')
                    var $value = document.getElementById('lang-picker-btn-value')

                    if (lang === 'de_DE') {
                        $value.innerText = 'Deutsch'
                    } else if (lang === 'ja_JP') {
                        $value.innerText = '日本語'
                    } else if (lang === 'fr_FR') {
                        $value.innerText = 'Français'
                    } else {
                        $value.innerText = 'English'
                    }
                    $lang.style.opacity = 1;

                    var langCook = getCookieValue('lang')
                    fetch('https://ipapi.co/country/').then(data => data.text()).then(r => {
                        console.info(r)
                        if (!langCook && !window.location.search.includes('lang=')) {
                            if (r === 'DE') {
                                changeLang('de_DE')
                            } else if (r === 'JP') {
                                changeLang('ja_JP')
                            } else if (r === 'FR') {
                                changeLang('fr_FR')
                            } else {
                                changeLang('en_US')
                            }
                        }
                        if (langCook && !['de_DE', 'ja_JP', 'fr_FR', 'en_US'].includes(langCook)) {
                            changeLang('en_US')
                        }
                        try {
                            $('.ui-autocomplete-input').val($('option[data-alternative-spellings~="' + r + '"]').val())
                        } catch (err) {
                            console.info('no country input')
                        }
                    }).catch(() => console.info('cannot locate user'))
                })
        }

        document.addEventListener("DOMContentLoaded", function () {
            init();
        });

        function replaceUrlParam(url, paramName, paramValue) {
            if (paramValue == null) {
                paramValue = '';
            }
            var pattern = new RegExp('\\b(' + paramName + '=).*?(&|#|$)');
            if (url.search(pattern) >= 0) {
                return url.replace(pattern, '$1' + paramValue + '$2');
            }
            url = url.replace(/[?#]$/, '');
            return url + (url.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + paramValue;
        }

        function changeLang(lang) {
            window.location.href = replaceUrlParam(window.location.href, 'lang', lang)
        }
    </script>
</div>

<div class="auth-modal-block auth-modal-login container padding-top-20 full-height">
    <h1 class="font-normal text-center margin-y-40" data-lang='title'></h1>
    <form id="login-form">
        <div class="input-group items-center login-type-input focus-input border flex bg-white margin-bottom-40">
            <img src="images/b2c-login/user.svg" class="icon margin-x-20" alt="user">
            <input class="box-sizing flex-1 padding-y-20" type="text" id="login_username" name="email"
                   data-lang-placeholder='username' placeholder=" "/>
        </div>
        <div class="input-group  login-type-input items-center border focus-input password-toggle  flex bg-white">
            <img src="images/b2c-login/lock.svg" class="icon margin-x-20" alt="user">
            <input class="box-sizing flex-1 padding-y-20 password_input" type="password" id="login_password"
                   name="password" data-lang-placeholder='password' placeholder="Password"/>
            <img src="images/b2c-login/eye.svg" class="icon margin-x-20 cursor-pointer show_password"
                 alt="Show password" aria-label="show passowd" role="button">
        </div>
        <div class="login-error-container color-red text-center margin-y-20"></div>
        <div class="input-group signup_pair text-center" style="height: 0px; opacity: 0; overflow:hidden">
            <input id="signup_pair_yes" class="box-sizing" type="radio" name="signup_pair" value="pair"/>
            <input id="signup_pair_no" class="box-sizing" type="radio" name="signup_pair" value="no_pair"/>
        </div>
        <div class="input-group margin-bottom-40">
            <div class="login_remember">
                <input class="checkbox form-radio" type="checkbox" id="login_remember" name="login_remember"/>
                <label for="login_remember" data-lang="remember"> </label>
                <br>
            </div>
        </div>
        <div class="input-group text-center">
            <button id="emokili_login_btn"
                    class="submit button small btn-full radius box-sizing btn block bg-blue color-white padding-20"
                    data-lang="login" type="submit"></button>
            <span class="forgotten_login"><a href="/forgot-password" title="Password Reminder Form"
                                             data-lang-title="password_form" class="block btn color-blue btn padding-20"
                                             data-lang="forgot">  </a></span>
            <p class="no-margin-top margin-bottom-40"><span data-lang="new_to_emokili">  </span> <a href="/signup"
                                                                                                    class="color-blue"
                                                                                                    data-lang="create_account"> </a>
            </p>
        </div>

        <hr class="margin-bottom-40">

        <h2 class="text-center margin-bottom-40 font-normal" data-lang="download_app"></h2>
        <div class="store-images text-center">
            <a href="https://itunes.apple.com/app/id977559373" class="inline-block margin-right-20">

                <img data-lang-src="app_store" src="../static/images/b2c-login/app-store-2x.png" alt="Emokili ios app">
            </a>
            <a href="http://play.google.com/store/apps/details?id=com.creedon.emokili" class="inline-block">
                <img data-lang-src="google_play" src="../static/images/b2c-login/play-store-2x.png"
                     alt="Emokili Android app">
            </a>

        </div>
    </form>
</div>

<div class="text-center margin-top-40 padding-y-20" data-lang="all_rights"></div>
<script>
    Array.from || (Array.from = function () {
        function h(r) {
            return "function" == typeof r || "[object Function]" === n.call(r)
        }

        function l(r) {
            var n = function (r) {
                var n = Number(r);
                return isNaN(n) ? 0 : 0 !== n && isFinite(n) ? (0 < n ? 1 : -1) * Math.floor(Math.abs(n)) : n
            }(r);
            return Math.min(Math.max(n, 0), t)
        }

        var n = Object.prototype.toString, t = Math.pow(2, 53) - 1;
        return function (r, n, t) {
            var e = Object(r);
            if (null == r) throw new TypeError("Array.from requires an array-like object - not null or undefined");
            var o, a = 1 < arguments.length ? n : void 0;
            if (void 0 !== a) {
                if (!h(a)) throw new TypeError("Array.from: when provided, the second argument must be a function");
                2 < arguments.length && (o = t)
            }
            for (var i, u = l(e.length), f = h(this) ? Object(new this(u)) : new Array(u), c = 0; c < u;) i = e[c], f[c] = a ? void 0 === o ? a(i, c) : a.call(o, i, c) : i, c += 1;
            return f.length = u, f
        }
    }());
</script>

<script>
    var lang


    function getParameterByName(nameInput, href) {
        const url = (href) ? href : window.location.href;
        const name = nameInput.replace(/[\[\]]/g, '\\$&');
        const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
        const results = regex.exec(url);
        if (!results) {
            return null;
        }
        if (!results[2]) {
            return '';
        }
        return decodeURIComponent(results[2].replace(/\+/g, ' '));
    }

    function translatePage() {
        var languageElements = Array.from(document.querySelectorAll('[data-lang], [data-lang-placeholder], [data-lang-src], [data-lang-title], [data-lang-href]'));
        languageElements.forEach(function (element) {
            var key = element.dataset.lang;
            if (key) element.innerHTML = USER_LANGUAGE[lang][key];
            var placeholder = element.dataset.langPlaceholder;
            if (placeholder) element.setAttribute('placeholder', USER_LANGUAGE[lang][placeholder]);
            var url = element.dataset.langHref;
            if (url) element.href = USER_LANGUAGE[lang][url];
            var src = element.dataset.langSrc;
            if (src) element.src = USER_LANGUAGE[lang][src];
            var title = element.dataset.langTitle;
            if (title) element.title = USER_LANGUAGE[lang][title];
        });
    }

    activeLang = (Cookies.get('lang')) ? Cookies.get('lang') : 'en_US';
    lang = (getParameterByName('lang')) ? getParameterByName('lang') : activeLang;
    lang = (lang === 'en_US' || lang === 'de_DE' || lang === 'ja_JP' || lang === 'fr_FR') ? lang : activeLang;
    Cookies.set('lang', lang);


    (function () {
        'use strict';
        var origin, languageElements, pair, activeLang, inputs, password_inputs;

        origin = getParameterByName('origin');
        var country = getParameterByName('country');
        var oldCountry = Cookies.get('country');
        if (country && country == 'us' || country == 'uk' || country == 'de') {
            Cookies.set('country', country)
        } else if (oldCountry) {
            country = Cookies.get('country')
        } else {
            country = 'us'
        }
        pair = getParameterByName('pair');


        if (origin) {
            Cookies.set('origin', origin);
        }
        if (pair) {
            document.getElementById('signup_pair_yes').checked = true;
        }

        translatePage();

        inputs = Array.from(document.getElementsByClassName('focus-input'));
        password_inputs = Array.from(document.getElementsByClassName('password-toggle'));

        inputs.forEach(function (element) {
            var input = element.querySelector('input')
            element.addEventListener('click', function () {
                input.focus();
                element.classList.add('focus')
            });
            if (input) {
                input.addEventListener('blur', function () {
                    element.classList.remove('focus')
                })
            }
        });

        password_inputs.forEach(function (element) {
            var passwordInput = element.querySelector('.password_input');
            var password = element.querySelector('.show_password');
            password.addEventListener('click', function () {
                passwordInput.type = (passwordInput.type === 'password') ? 'text' : 'password';
            });
        });

    })();
</script>

<form id="loginRedirectForm" action="http://127.0.0.1:8002/web/www-login-redirect" method="POST">
    <input type="hidden" name="token" value=""/>
    <input type="hidden" name="startPairing" value="false"/>
    <input type="hidden" name="redirectPath"/>
</form>

<script src="https://code.jquery.com/jquery-2.2.4.min.js"
        integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"
        integrity="sha256-xNjb53/rY+WmG+4L6tTl9m6PpqknWZvRt0rO1SRnJzw=" crossorigin="anonymous"></script>


<script>

    (function () {
        'use strict';
        var origin, lang, inputs, password_inputs, languageElements, pair, activeLang;

        function getParameterByName(nameInput, href) {
            const url = (href) ? href : window.location.href;
            const name = nameInput.replace(/[\[\]]/g, '\\$&');
            const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
            const results = regex.exec(url);
            if (!results) {
                return null;
            }
            if (!results[2]) {
                return '';
            }
            return decodeURIComponent(results[2].replace(/\+/g, ' '));
        }

        origin = getParameterByName('origin');
        pair = getParameterByName('pair');
        if (pair) {
            $('#signup_pair_yes').prop('checked', true);
        }

    })();

</script>


<script>
    (function (definition) {
        if (typeof bootstrap === "function") {
            bootstrap("promise", definition)
        } else if (typeof exports === "object") {
            module.exports = definition()
        } else if (typeof define === "function" && define.amd) {
            define(definition)
        } else if (typeof ses !== "undefined") {
            if (!ses.ok()) {
                return
            } else {
                ses.makeQ = definition
            }
        } else {
            Q = definition()
        }
    })(function () {
        "use strict";
        var hasStacks = !1;
        try {
            throw new Error()
        } catch (e) {
            hasStacks = !!e.stack
        }
        var qStartingLine = captureLine();
        var qFileName;
        var noop = function () {
        };
        var nextTick = (function () {
            var head = {task: void 0, next: null};
            var tail = head;
            var flushing = !1;
            var requestTick = void 0;
            var isNodeJS = !1;

            function flush() {
                while (head.next) {
                    head = head.next;
                    var task = head.task;
                    head.task = void 0;
                    var domain = head.domain;
                    if (domain) {
                        head.domain = void 0;
                        domain.enter()
                    }
                    try {
                        task()
                    } catch (e) {
                        if (isNodeJS) {
                            if (domain) {
                                domain.exit()
                            }
                            setTimeout(flush, 0);
                            if (domain) {
                                domain.enter()
                            }
                            throw e
                        } else {
                            setTimeout(function () {
                                throw e
                            }, 0)
                        }
                    }
                    if (domain) {
                        domain.exit()
                    }
                }
                flushing = !1
            }

            nextTick = function (task) {
                tail = tail.next = {task: task, domain: isNodeJS && process.domain, next: null};
                if (!flushing) {
                    flushing = !0;
                    requestTick()
                }
            };
            if (typeof process !== "undefined" && process.nextTick) {
                isNodeJS = !0;
                requestTick = function () {
                    process.nextTick(flush)
                }
            } else if (typeof setImmediate === "function") {
                if (typeof window !== "undefined") {
                    requestTick = setImmediate.bind(window, flush)
                } else {
                    requestTick = function () {
                        setImmediate(flush)
                    }
                }
            } else if (typeof MessageChannel !== "undefined") {
                var channel = new MessageChannel();
                channel.port1.onmessage = function () {
                    requestTick = requestPortTick;
                    channel.port1.onmessage = flush;
                    flush()
                };
                var requestPortTick = function () {
                    channel.port2.postMessage(0)
                };
                requestTick = function () {
                    setTimeout(flush, 0);
                    requestPortTick()
                }
            } else {
                requestTick = function () {
                    setTimeout(flush, 0)
                }
            }
            return nextTick
        })();
        var call = Function.call;

        function uncurryThis(f) {
            return function () {
                return call.apply(f, arguments)
            }
        }

        var array_slice = uncurryThis(Array.prototype.slice);
        var array_reduce = uncurryThis(Array.prototype.reduce || function (callback, basis) {
            var index = 0, length = this.length;
            if (arguments.length === 1) {
                do {
                    if (index in this) {
                        basis = this[index++];
                        break
                    }
                    if (++index >= length) {
                        throw new TypeError()
                    }
                } while (1);
            }
            for (; index < length; index++) {
                if (index in this) {
                    basis = callback(basis, this[index], index)
                }
            }
            return basis
        });
        var array_indexOf = uncurryThis(Array.prototype.indexOf || function (value) {
            for (var i = 0; i < this.length; i++) {
                if (this[i] === value) {
                    return i
                }
            }
            return -1
        });
        var array_map = uncurryThis(Array.prototype.map || function (callback, thisp) {
            var self = this;
            var collect = [];
            array_reduce(self, function (undefined, value, index) {
                collect.push(callback.call(thisp, value, index, self))
            }, void 0);
            return collect
        });
        var object_create = Object.create || function (prototype) {
            function Type() {
            }

            Type.prototype = prototype;
            return new Type()
        };
        var object_hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);
        var object_keys = Object.keys || function (object) {
            var keys = [];
            for (var key in object) {
                if (object_hasOwnProperty(object, key)) {
                    keys.push(key)
                }
            }
            return keys
        };
        var object_toString = uncurryThis(Object.prototype.toString);

        function isObject(value) {
            return value === Object(value)
        }

        function isStopIteration(exception) {
            return (object_toString(exception) === "[object StopIteration]" || exception instanceof QReturnValue)
        }

        var QReturnValue;
        if (typeof ReturnValue !== "undefined") {
            QReturnValue = ReturnValue
        } else {
            QReturnValue = function (value) {
                this.value = value
            }
        }
        var STACK_JUMP_SEPARATOR = "From previous event:";

        function makeStackTraceLong(error, promise) {
            if (hasStacks && promise.stack && typeof error === "object" && error !== null && error.stack && error.stack.indexOf(STACK_JUMP_SEPARATOR) === -1) {
                var stacks = [];
                for (var p = promise; !!p; p = p.source) {
                    if (p.stack) {
                        stacks.unshift(p.stack)
                    }
                }
                stacks.unshift(error.stack);
                var concatedStacks = stacks.join("\n" + STACK_JUMP_SEPARATOR + "\n");
                error.stack = filterStackString(concatedStacks)
            }
        }

        function filterStackString(stackString) {
            var lines = stackString.split("\n");
            var desiredLines = [];
            for (var i = 0; i < lines.length; ++i) {
                var line = lines[i];
                if (!isInternalFrame(line) && !isNodeFrame(line) && line) {
                    desiredLines.push(line)
                }
            }
            return desiredLines.join("\n")
        }

        function isNodeFrame(stackLine) {
            return stackLine.indexOf("(module.js:") !== -1 || stackLine.indexOf("(node.js:") !== -1
        }

        function getFileNameAndLineNumber(stackLine) {
            var attempt1 = /at .+ \((.+):(\d+):(?:\d+)\)$/.exec(stackLine);
            if (attempt1) {
                return [attempt1[1], Number(attempt1[2])]
            }
            var attempt2 = /at ([^ ]+):(\d+):(?:\d+)$/.exec(stackLine);
            if (attempt2) {
                return [attempt2[1], Number(attempt2[2])]
            }
            var attempt3 = /.*@(.+):(\d+)$/.exec(stackLine);
            if (attempt3) {
                return [attempt3[1], Number(attempt3[2])]
            }
        }

        function isInternalFrame(stackLine) {
            var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);
            if (!fileNameAndLineNumber) {
                return !1
            }
            var fileName = fileNameAndLineNumber[0];
            var lineNumber = fileNameAndLineNumber[1];
            return fileName === qFileName && lineNumber >= qStartingLine && lineNumber <= qEndingLine
        }

        function captureLine() {
            if (!hasStacks) {
                return
            }
            try {
                throw new Error()
            } catch (e) {
                var lines = e.stack.split("\n");
                var firstLine = lines[0].indexOf("@") > 0 ? lines[1] : lines[2];
                var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);
                if (!fileNameAndLineNumber) {
                    return
                }
                qFileName = fileNameAndLineNumber[0];
                return fileNameAndLineNumber[1]
            }
        }

        function deprecate(callback, name, alternative) {
            return function () {
                if (typeof console !== "undefined" && typeof console.warn === "function") {
                    console.warn(name + " is deprecated, use " + alternative + " instead.", new Error("").stack)
                }
                return callback.apply(callback, arguments)
            }
        }

        function Q(value) {
            if (isPromise(value)) {
                return value
            }
            if (isPromiseAlike(value)) {
                return coerce(value)
            } else {
                return fulfill(value)
            }
        }

        Q.resolve = Q;
        Q.nextTick = nextTick;
        Q.longStackSupport = !1;
        Q.defer = defer;

        function defer() {
            var messages = [], progressListeners = [], resolvedPromise;
            var deferred = object_create(defer.prototype);
            var promise = object_create(Promise.prototype);
            promise.promiseDispatch = function (resolve, op, operands) {
                var args = array_slice(arguments);
                if (messages) {
                    messages.push(args);
                    if (op === "when" && operands[1]) {
                        progressListeners.push(operands[1])
                    }
                } else {
                    nextTick(function () {
                        resolvedPromise.promiseDispatch.apply(resolvedPromise, args)
                    })
                }
            };
            promise.valueOf = function () {
                if (messages) {
                    return promise
                }
                var nearerValue = nearer(resolvedPromise);
                if (isPromise(nearerValue)) {
                    resolvedPromise = nearerValue
                }
                return nearerValue
            };
            promise.inspect = function () {
                if (!resolvedPromise) {
                    return {state: "pending"}
                }
                return resolvedPromise.inspect()
            };
            if (Q.longStackSupport && hasStacks) {
                try {
                    throw new Error()
                } catch (e) {
                    promise.stack = e.stack.substring(e.stack.indexOf("\n") + 1)
                }
            }

            function become(newPromise) {
                resolvedPromise = newPromise;
                promise.source = newPromise;
                array_reduce(messages, function (undefined, message) {
                    nextTick(function () {
                        newPromise.promiseDispatch.apply(newPromise, message)
                    })
                }, void 0);
                messages = void 0;
                progressListeners = void 0
            }

            deferred.promise = promise;
            deferred.resolve = function (value) {
                if (resolvedPromise) {
                    return
                }
                become(Q(value))
            };
            deferred.fulfill = function (value) {
                if (resolvedPromise) {
                    return
                }
                become(fulfill(value))
            };
            deferred.reject = function (reason) {
                if (resolvedPromise) {
                    return
                }
                become(reject(reason))
            };
            deferred.notify = function (progress) {
                if (resolvedPromise) {
                    return
                }
                array_reduce(progressListeners, function (undefined, progressListener) {
                    nextTick(function () {
                        progressListener(progress)
                    })
                }, void 0)
            };
            return deferred
        }

        defer.prototype.makeNodeResolver = function () {
            var self = this;
            return function (error, value) {
                if (error) {
                    self.reject(error)
                } else if (arguments.length > 2) {
                    self.resolve(array_slice(arguments, 1))
                } else {
                    self.resolve(value)
                }
            }
        };
        Q.Promise = promise;
        Q.promise = promise;

        function promise(resolver) {
            if (typeof resolver !== "function") {
                throw new TypeError("resolver must be a function.")
            }
            var deferred = defer();
            try {
                resolver(deferred.resolve, deferred.reject, deferred.notify)
            } catch (reason) {
                deferred.reject(reason)
            }
            return deferred.promise
        }

        promise.race = race;
        promise.all = all;
        promise.reject = reject;
        promise.resolve = Q;
        Q.passByCopy = function (object) {
            return object
        };
        Promise.prototype.passByCopy = function () {
            return this
        };
        Q.join = function (x, y) {
            return Q(x).join(y)
        };
        Promise.prototype.join = function (that) {
            return Q([this, that]).spread(function (x, y) {
                if (x === y) {
                    return x
                } else {
                    throw new Error("Can't join: not the same: " + x + " " + y)
                }
            })
        };
        Q.race = race;

        function race(answerPs) {
            return promise(function (resolve, reject) {
                for (var i = 0, len = answerPs.length; i < len; i++) {
                    Q(answerPs[i]).then(resolve, reject)
                }
            })
        }

        Promise.prototype.race = function () {
            return this.then(Q.race)
        };
        Q.makePromise = Promise;

        function Promise(descriptor, fallback, inspect) {
            if (fallback === void 0) {
                fallback = function (op) {
                    return reject(new Error("Promise does not support operation: " + op))
                }
            }
            if (inspect === void 0) {
                inspect = function () {
                    return {state: "unknown"}
                }
            }
            var promise = object_create(Promise.prototype);
            promise.promiseDispatch = function (resolve, op, args) {
                var result;
                try {
                    if (descriptor[op]) {
                        result = descriptor[op].apply(promise, args)
                    } else {
                        result = fallback.call(promise, op, args)
                    }
                } catch (exception) {
                    result = reject(exception)
                }
                if (resolve) {
                    resolve(result)
                }
            };
            promise.inspect = inspect;
            if (inspect) {
                var inspected = inspect();
                if (inspected.state === "rejected") {
                    promise.exception = inspected.reason
                }
                promise.valueOf = function () {
                    var inspected = inspect();
                    if (inspected.state === "pending" || inspected.state === "rejected") {
                        return promise
                    }
                    return inspected.value
                }
            }
            return promise
        }

        Promise.prototype.toString = function () {
            return "[object Promise]"
        };
        Promise.prototype.then = function (fulfilled, rejected, progressed) {
            var self = this;
            var deferred = defer();
            var done = !1;

            function _fulfilled(value) {
                try {
                    return typeof fulfilled === "function" ? fulfilled(value) : value
                } catch (exception) {
                    return reject(exception)
                }
            }

            function _rejected(exception) {
                if (typeof rejected === "function") {
                    makeStackTraceLong(exception, self);
                    try {
                        return rejected(exception)
                    } catch (newException) {
                        return reject(newException)
                    }
                }
                return reject(exception)
            }

            function _progressed(value) {
                return typeof progressed === "function" ? progressed(value) : value
            }

            nextTick(function () {
                self.promiseDispatch(function (value) {
                    if (done) {
                        return
                    }
                    done = !0;
                    deferred.resolve(_fulfilled(value))
                }, "when", [function (exception) {
                    if (done) {
                        return
                    }
                    done = !0;
                    deferred.resolve(_rejected(exception))
                }])
            });
            self.promiseDispatch(void 0, "when", [void 0, function (value) {
                var newValue;
                var threw = !1;
                try {
                    newValue = _progressed(value)
                } catch (e) {
                    threw = !0;
                    if (Q.onerror) {
                        Q.onerror(e)
                    } else {
                        throw e
                    }
                }
                if (!threw) {
                    deferred.notify(newValue)
                }
            }]);
            return deferred.promise
        };
        Q.when = when;

        function when(value, fulfilled, rejected, progressed) {
            return Q(value).then(fulfilled, rejected, progressed)
        }

        Promise.prototype.thenResolve = function (value) {
            return this.then(function () {
                return value
            })
        };
        Q.thenResolve = function (promise, value) {
            return Q(promise).thenResolve(value)
        };
        Promise.prototype.thenReject = function (reason) {
            return this.then(function () {
                throw reason
            })
        };
        Q.thenReject = function (promise, reason) {
            return Q(promise).thenReject(reason)
        };
        Q.nearer = nearer;

        function nearer(value) {
            if (isPromise(value)) {
                var inspected = value.inspect();
                if (inspected.state === "fulfilled") {
                    return inspected.value
                }
            }
            return value
        }

        Q.isPromise = isPromise;

        function isPromise(object) {
            return isObject(object) && typeof object.promiseDispatch === "function" && typeof object.inspect === "function"
        }

        Q.isPromiseAlike = isPromiseAlike;

        function isPromiseAlike(object) {
            return isObject(object) && typeof object.then === "function"
        }

        Q.isPending = isPending;

        function isPending(object) {
            return isPromise(object) && object.inspect().state === "pending"
        }

        Promise.prototype.isPending = function () {
            return this.inspect().state === "pending"
        };
        Q.isFulfilled = isFulfilled;

        function isFulfilled(object) {
            return !isPromise(object) || object.inspect().state === "fulfilled"
        }

        Promise.prototype.isFulfilled = function () {
            return this.inspect().state === "fulfilled"
        };
        Q.isRejected = isRejected;

        function isRejected(object) {
            return isPromise(object) && object.inspect().state === "rejected"
        }

        Promise.prototype.isRejected = function () {
            return this.inspect().state === "rejected"
        };
        var unhandledReasons = [];
        var unhandledRejections = [];
        var trackUnhandledRejections = !0;

        function resetUnhandledRejections() {
            unhandledReasons.length = 0;
            unhandledRejections.length = 0;
            if (!trackUnhandledRejections) {
                trackUnhandledRejections = !0
            }
        }

        function trackRejection(promise, reason) {
            if (!trackUnhandledRejections) {
                return
            }
            unhandledRejections.push(promise);
            if (reason && typeof reason.stack !== "undefined") {
                unhandledReasons.push(reason.stack)
            } else {
                unhandledReasons.push("(no stack) " + reason)
            }
        }

        function untrackRejection(promise) {
            if (!trackUnhandledRejections) {
                return
            }
            var at = array_indexOf(unhandledRejections, promise);
            if (at !== -1) {
                unhandledRejections.splice(at, 1);
                unhandledReasons.splice(at, 1)
            }
        }

        Q.resetUnhandledRejections = resetUnhandledRejections;
        Q.getUnhandledReasons = function () {
            return unhandledReasons.slice()
        };
        Q.stopUnhandledRejectionTracking = function () {
            resetUnhandledRejections();
            trackUnhandledRejections = !1
        };
        resetUnhandledRejections();
        Q.reject = reject;

        function reject(reason) {
            var rejection = Promise({
                "when": function (rejected) {
                    if (rejected) {
                        untrackRejection(this)
                    }
                    return rejected ? rejected(reason) : this
                }
            }, function fallback() {
                return this
            }, function inspect() {
                return {state: "rejected", reason: reason}
            });
            trackRejection(rejection, reason);
            return rejection
        }

        Q.fulfill = fulfill;

        function fulfill(value) {
            return Promise({
                "when": function () {
                    return value
                }, "get": function (name) {
                    return value[name]
                }, "set": function (name, rhs) {
                    value[name] = rhs
                }, "delete": function (name) {
                    delete value[name]
                }, "post": function (name, args) {
                    if (name === null || name === void 0) {
                        return value.apply(void 0, args)
                    } else {
                        return value[name].apply(value, args)
                    }
                }, "apply": function (thisp, args) {
                    return value.apply(thisp, args)
                }, "keys": function () {
                    return object_keys(value)
                }
            }, void 0, function inspect() {
                return {state: "fulfilled", value: value}
            })
        }

        function coerce(promise) {
            var deferred = defer();
            nextTick(function () {
                try {
                    promise.then(deferred.resolve, deferred.reject, deferred.notify)
                } catch (exception) {
                    deferred.reject(exception)
                }
            });
            return deferred.promise
        }

        Q.master = master;

        function master(object) {
            return Promise({
                "isDef": function () {
                }
            }, function fallback(op, args) {
                return dispatch(object, op, args)
            }, function () {
                return Q(object).inspect()
            })
        }

        Q.spread = spread;

        function spread(value, fulfilled, rejected) {
            return Q(value).spread(fulfilled, rejected)
        }

        Promise.prototype.spread = function (fulfilled, rejected) {
            return this.all().then(function (array) {
                return fulfilled.apply(void 0, array)
            }, rejected)
        };
        Q.async = async;

        function async(makeGenerator) {
            return function () {
                function continuer(verb, arg) {
                    var result;
                    if (typeof StopIteration === "undefined") {
                        try {
                            result = generator[verb](arg)
                        } catch (exception) {
                            return reject(exception)
                        }
                        if (result.done) {
                            return result.value
                        } else {
                            return when(result.value, callback, errback)
                        }
                    } else {
                        try {
                            result = generator[verb](arg)
                        } catch (exception) {
                            if (isStopIteration(exception)) {
                                return exception.value
                            } else {
                                return reject(exception)
                            }
                        }
                        return when(result, callback, errback)
                    }
                }

                var generator = makeGenerator.apply(this, arguments);
                var callback = continuer.bind(continuer, "next");
                var errback = continuer.bind(continuer, "throw");
                return callback()
            }
        }

        Q.spawn = spawn;

        function spawn(makeGenerator) {
            Q.done(Q.async(makeGenerator)())
        }

        Q["return"] = _return;

        function _return(value) {
            throw new QReturnValue(value)
        }

        Q.promised = promised;

        function promised(callback) {
            return function () {
                return spread([this, all(arguments)], function (self, args) {
                    return callback.apply(self, args)
                })
            }
        }

        Q.dispatch = dispatch;

        function dispatch(object, op, args) {
            return Q(object).dispatch(op, args)
        }

        Promise.prototype.dispatch = function (op, args) {
            var self = this;
            var deferred = defer();
            nextTick(function () {
                self.promiseDispatch(deferred.resolve, op, args)
            });
            return deferred.promise
        };
        Q.get = function (object, key) {
            return Q(object).dispatch("get", [key])
        };
        Promise.prototype.get = function (key) {
            return this.dispatch("get", [key])
        };
        Q.set = function (object, key, value) {
            return Q(object).dispatch("set", [key, value])
        };
        Promise.prototype.set = function (key, value) {
            return this.dispatch("set", [key, value])
        };
        Q.del = Q["delete"] = function (object, key) {
            return Q(object).dispatch("delete", [key])
        };
        Promise.prototype.del = Promise.prototype["delete"] = function (key) {
            return this.dispatch("delete", [key])
        };
        Q.mapply = Q.post = function (object, name, args) {
            return Q(object).dispatch("post", [name, args])
        };
        Promise.prototype.mapply = Promise.prototype.post = function (name, args) {
            return this.dispatch("post", [name, args])
        };
        Q.send = Q.mcall = Q.invoke = function (object, name) {
            return Q(object).dispatch("post", [name, array_slice(arguments, 2)])
        };
        Promise.prototype.send = Promise.prototype.mcall = Promise.prototype.invoke = function (name) {
            return this.dispatch("post", [name, array_slice(arguments, 1)])
        };
        Q.fapply = function (object, args) {
            return Q(object).dispatch("apply", [void 0, args])
        };
        Promise.prototype.fapply = function (args) {
            return this.dispatch("apply", [void 0, args])
        };
        Q["try"] = Q.fcall = function (object) {
            return Q(object).dispatch("apply", [void 0, array_slice(arguments, 1)])
        };
        Promise.prototype.fcall = function () {
            return this.dispatch("apply", [void 0, array_slice(arguments)])
        };
        Q.fbind = function (object) {
            var promise = Q(object);
            var args = array_slice(arguments, 1);
            return function fbound() {
                return promise.dispatch("apply", [this, args.concat(array_slice(arguments))])
            }
        };
        Promise.prototype.fbind = function () {
            var promise = this;
            var args = array_slice(arguments);
            return function fbound() {
                return promise.dispatch("apply", [this, args.concat(array_slice(arguments))])
            }
        };
        Q.keys = function (object) {
            return Q(object).dispatch("keys", [])
        };
        Promise.prototype.keys = function () {
            return this.dispatch("keys", [])
        };
        Q.all = all;

        function all(promises) {
            return when(promises, function (promises) {
                var countDown = 0;
                var deferred = defer();
                array_reduce(promises, function (undefined, promise, index) {
                    var snapshot;
                    if (isPromise(promise) && (snapshot = promise.inspect()).state === "fulfilled") {
                        promises[index] = snapshot.value
                    } else {
                        ++countDown;
                        when(promise, function (value) {
                            promises[index] = value;
                            if (--countDown === 0) {
                                deferred.resolve(promises)
                            }
                        }, deferred.reject, function (progress) {
                            deferred.notify({index: index, value: progress})
                        })
                    }
                }, void 0);
                if (countDown === 0) {
                    deferred.resolve(promises)
                }
                return deferred.promise
            })
        }

        Promise.prototype.all = function () {
            return all(this)
        };
        Q.allResolved = deprecate(allResolved, "allResolved", "allSettled");

        function allResolved(promises) {
            return when(promises, function (promises) {
                promises = array_map(promises, Q);
                return when(all(array_map(promises, function (promise) {
                    return when(promise, noop, noop)
                })), function () {
                    return promises
                })
            })
        }

        Promise.prototype.allResolved = function () {
            return allResolved(this)
        };
        Q.allSettled = allSettled;

        function allSettled(promises) {
            return Q(promises).allSettled()
        }

        Promise.prototype.allSettled = function () {
            return this.then(function (promises) {
                return all(array_map(promises, function (promise) {
                    promise = Q(promise);

                    function regardless() {
                        return promise.inspect()
                    }

                    return promise.then(regardless, regardless)
                }))
            })
        };
        Q.fail = Q["catch"] = function (object, rejected) {
            return Q(object).then(void 0, rejected)
        };
        Promise.prototype.fail = Promise.prototype["catch"] = function (rejected) {
            return this.then(void 0, rejected)
        };
        Q.progress = progress;

        function progress(object, progressed) {
            return Q(object).then(void 0, void 0, progressed)
        }

        Promise.prototype.progress = function (progressed) {
            return this.then(void 0, void 0, progressed)
        };
        Q.fin = Q["finally"] = function (object, callback) {
            return Q(object)["finally"](callback)
        };
        Promise.prototype.fin = Promise.prototype["finally"] = function (callback) {
            callback = Q(callback);
            return this.then(function (value) {
                return callback.fcall().then(function () {
                    return value
                })
            }, function (reason) {
                return callback.fcall().then(function () {
                    throw reason
                })
            })
        };
        Q.done = function (object, fulfilled, rejected, progress) {
            return Q(object).done(fulfilled, rejected, progress)
        };
        Promise.prototype.done = function (fulfilled, rejected, progress) {
            var onUnhandledError = function (error) {
                nextTick(function () {
                    makeStackTraceLong(error, promise);
                    if (Q.onerror) {
                        Q.onerror(error)
                    } else {
                        throw error
                    }
                })
            };
            var promise = fulfilled || rejected || progress ? this.then(fulfilled, rejected, progress) : this;
            if (typeof process === "object" && process && process.domain) {
                onUnhandledError = process.domain.bind(onUnhandledError)
            }
            promise.then(void 0, onUnhandledError)
        };
        Q.timeout = function (object, ms, message) {
            return Q(object).timeout(ms, message)
        };
        Promise.prototype.timeout = function (ms, message) {
            var deferred = defer();
            var timeoutId = setTimeout(function () {
                deferred.reject(new Error(message || "Timed out after " + ms + " ms"))
            }, ms);
            this.then(function (value) {
                clearTimeout(timeoutId);
                deferred.resolve(value)
            }, function (exception) {
                clearTimeout(timeoutId);
                deferred.reject(exception)
            }, deferred.notify);
            return deferred.promise
        };
        Q.delay = function (object, timeout) {
            if (timeout === void 0) {
                timeout = object;
                object = void 0
            }
            return Q(object).delay(timeout)
        };
        Promise.prototype.delay = function (timeout) {
            return this.then(function (value) {
                var deferred = defer();
                setTimeout(function () {
                    deferred.resolve(value)
                }, timeout);
                return deferred.promise
            })
        };
        Q.nfapply = function (callback, args) {
            return Q(callback).nfapply(args)
        };
        Promise.prototype.nfapply = function (args) {
            var deferred = defer();
            var nodeArgs = array_slice(args);
            nodeArgs.push(deferred.makeNodeResolver());
            this.fapply(nodeArgs).fail(deferred.reject);
            return deferred.promise
        };
        Q.nfcall = function (callback) {
            var args = array_slice(arguments, 1);
            return Q(callback).nfapply(args)
        };
        Promise.prototype.nfcall = function () {
            var nodeArgs = array_slice(arguments);
            var deferred = defer();
            nodeArgs.push(deferred.makeNodeResolver());
            this.fapply(nodeArgs).fail(deferred.reject);
            return deferred.promise
        };
        Q.nfbind = Q.denodeify = function (callback) {
            var baseArgs = array_slice(arguments, 1);
            return function () {
                var nodeArgs = baseArgs.concat(array_slice(arguments));
                var deferred = defer();
                nodeArgs.push(deferred.makeNodeResolver());
                Q(callback).fapply(nodeArgs).fail(deferred.reject);
                return deferred.promise
            }
        };
        Promise.prototype.nfbind = Promise.prototype.denodeify = function () {
            var args = array_slice(arguments);
            args.unshift(this);
            return Q.denodeify.apply(void 0, args)
        };
        Q.nbind = function (callback, thisp) {
            var baseArgs = array_slice(arguments, 2);
            return function () {
                var nodeArgs = baseArgs.concat(array_slice(arguments));
                var deferred = defer();
                nodeArgs.push(deferred.makeNodeResolver());

                function bound() {
                    return callback.apply(thisp, arguments)
                }

                Q(bound).fapply(nodeArgs).fail(deferred.reject);
                return deferred.promise
            }
        };
        Promise.prototype.nbind = function () {
            var args = array_slice(arguments, 0);
            args.unshift(this);
            return Q.nbind.apply(void 0, args)
        };
        Q.nmapply = Q.npost = function (object, name, args) {
            return Q(object).npost(name, args)
        };
        Promise.prototype.nmapply = Promise.prototype.npost = function (name, args) {
            var nodeArgs = array_slice(args || []);
            var deferred = defer();
            nodeArgs.push(deferred.makeNodeResolver());
            this.dispatch("post", [name, nodeArgs]).fail(deferred.reject);
            return deferred.promise
        };
        Q.nsend = Q.nmcall = Q.ninvoke = function (object, name) {
            var nodeArgs = array_slice(arguments, 2);
            var deferred = defer();
            nodeArgs.push(deferred.makeNodeResolver());
            Q(object).dispatch("post", [name, nodeArgs]).fail(deferred.reject);
            return deferred.promise
        };
        Promise.prototype.nsend = Promise.prototype.nmcall = Promise.prototype.ninvoke = function (name) {
            var nodeArgs = array_slice(arguments, 1);
            var deferred = defer();
            nodeArgs.push(deferred.makeNodeResolver());
            this.dispatch("post", [name, nodeArgs]).fail(deferred.reject);
            return deferred.promise
        };
        Q.nodeify = nodeify;

        function nodeify(object, nodeback) {
            return Q(object).nodeify(nodeback)
        }

        Promise.prototype.nodeify = function (nodeback) {
            if (nodeback) {
                this.then(function (value) {
                    nextTick(function () {
                        nodeback(null, value)
                    })
                }, function (error) {
                    nextTick(function () {
                        nodeback(error)
                    })
                })
            } else {
                return this
            }
        };
        var qEndingLine = captureLine();
        return Q
    })
</script>


<script>
    var defaultCountry, uk, de;
    us = '<option value="United States" data-relevancy-booster="3.5" data-alternative-spellings="US USA United States of America">United States</option>';
    uk = '<option value="United Kingdom" data-alternative-spellings="GB Great Britain England UK Wales Scotland Northern Ireland" data-relevancy-booster="2.5">United Kingdom</option>';
    de = '<option value="Germany" data-alternative-spellings="DE Bundesrepublik Deutschland" data-relevancy-booster="3">Germany</option>';
    var country = (Cookies.get('country')) ? Cookies.get('country') : 'us';
    if (country == 'de') {
        defaultCountry = de + uk + us;
    } else if (country == 'uk') {
        defaultCountry = uk + us + de;
    } else {
        defaultCountry = us + uk + de;
    }


    var SelectCountry = {
        init: function () {
            this.buildList($(".select_country")), $(".select_country").selectToAutocomplete(), $("input.select_country").prop("type", "text")
        }, buildList: function (a) {
            a.html(defaultCountry + '<option value="Afghanistan" data-alternative-spellings="AF افغانستان">Afghanistan</option><option value="Åland Islands" data-alternative-spellings="AX Aaland Aland" data-relevancy-booster="0.5">Åland Islands</option><option value="Albania" data-alternative-spellings="AL">Albania</option><option value="Algeria" data-alternative-spellings="DZ الجزائر">Algeria</option><option value="American Samoa" data-alternative-spellings="AS" data-relevancy-booster="0.5">American Samoa</option><option value="Andorra" data-alternative-spellings="AD" data-relevancy-booster="0.5">Andorra</option><option value="Angola" data-alternative-spellings="AO">Angola</option><option value="Anguilla" data-alternative-spellings="AI" data-relevancy-booster="0.5">Anguilla</option><option value="Antarctica" data-alternative-spellings="AQ" data-relevancy-booster="0.5">Antarctica</option><option value="Antigua And Barbuda" data-alternative-spellings="AG" data-relevancy-booster="0.5">Antigua And Barbuda</option><option value="Argentina" data-alternative-spellings="AR">Argentina</option><option value="Armenia" data-alternative-spellings="AM Հայաստան">Armenia</option><option value="Aruba" data-alternative-spellings="AW" data-relevancy-booster="0.5">Aruba</option><option value="Australia" data-alternative-spellings="AU" data-relevancy-booster="1.5">Australia</option><option value="Austria" data-alternative-spellings="AT Österreich Osterreich Ohesterreich ">Austria</option><option value="Azerbaijan" data-alternative-spellings="AZ">Azerbaijan</option><option value="Bahamas" data-alternative-spellings="BS">Bahamas</option><option value="Bahrain" data-alternative-spellings="BH البحرين">Bahrain</option><option value="Bangladesh" data-alternative-spellings="BD বাংলাদেশ" data-relevancy-booster="2">Bangladesh</option><option value="Barbados" data-alternative-spellings="BB">Barbados</option><option value="Belarus" data-alternative-spellings="BY Беларусь">Belarus</option><option value="Belgium" data-alternative-spellings="BE België Belgie Belgien Belgique" data-relevancy-booster="1.5">Belgium</option><option value="Belize" data-alternative-spellings="BZ">Belize</option><option value="Benin" data-alternative-spellings="BJ">Benin</option><option value="Bermuda" data-alternative-spellings="BM" data-relevancy-booster="0.5">Bermuda</option><option value="Bhutan" data-alternative-spellings="BT भूटान">Bhutan</option><option value="Bolivia" data-alternative-spellings="BO">Bolivia</option><option value="Bonaire, Sint Eustatius and Saba" data-alternative-spellings="BQ">Bonaire, Sint Eustatius and Saba</option><option value="Bosnia and Herzegovina" data-alternative-spellings="BA Босна и Херцеговина">Bosnia and Herzegovina</option><option value="Botswana" data-alternative-spellings="BW">Botswana</option><option value="Bouvet Island" data-alternative-spellings="BV">Bouvet Island</option><option value="Brazil" data-alternative-spellings="BR Brasil" data-relevancy-booster="2">Brazil</option><option value="British Indian Ocean Territory" data-alternative-spellings="IO">British Indian Ocean Territory</option><option value="Brunei Darussalam" data-alternative-spellings="BN">Brunei Darussalam</option><option value="Bulgaria" data-alternative-spellings="BG България">Bulgaria</option><option value="Burkina Faso" data-alternative-spellings="BF">Burkina Faso</option><option value="Burundi" data-alternative-spellings="BI">Burundi</option><option value="Cambodia" data-alternative-spellings="KH កម្ពុជា">Cambodia</option><option value="Cameroon" data-alternative-spellings="CM">Cameroon</option><option value="Canada" data-alternative-spellings="CA" data-relevancy-booster="2">Canada</option><option value="Cape Verde" data-alternative-spellings="CV Cabo">Cape Verde</option><option value="Cayman Islands" data-alternative-spellings="KY" data-relevancy-booster="0.5">Cayman Islands</option><option value="Central African Republic" data-alternative-spellings="CF">Central African Republic</option><option value="Chad" data-alternative-spellings="TD تشاد‎ Tchad">Chad</option><option value="Chile" data-alternative-spellings="CL">Chile</option><option value="China" data-relevancy-booster="3.5" data-alternative-spellings="CN Zhongguo Zhonghua Peoples Republic 中国/中华">China</option><option value="Christmas Island" data-alternative-spellings="CX" data-relevancy-booster="0.5">Christmas Island</option><option value="Cocos (Keeling) Islands" data-alternative-spellings="CC" data-relevancy-booster="0.5">Cocos (Keeling) Islands</option><option value="Colombia" data-alternative-spellings="CO">Colombia</option><option value="Comoros" data-alternative-spellings="KM جزر القمر">Comoros</option><option value="Congo" data-alternative-spellings="CG">Congo</option><option value="Congo, the Democratic Republic of the" data-alternative-spellings="CD Congo-Brazzaville Repubilika ya Kongo">Congo, the Democratic Republic of the</option><option value="Cook Islands" data-alternative-spellings="CK" data-relevancy-booster="0.5">Cook Islands</option><option value="Costa Rica" data-alternative-spellings="CR">Costa Rica</option><option value="Côte d\'Ivoire" data-alternative-spellings="CI Cote dIvoire">Côte d\'Ivoire</option><option value="Croatia" data-alternative-spellings="HR Hrvatska">Croatia</option><option value="Cuba" data-alternative-spellings="CU">Cuba</option><option value="Curaçao" data-alternative-spellings="CW Curacao">Curaçao</option><option value="Cyprus" data-alternative-spellings="CY Κύπρος Kýpros Kıbrıs">Cyprus</option><option value="Czech Republic" data-alternative-spellings="CZ Česká Ceska">Czech Republic</option><option value="Denmark" data-alternative-spellings="DK Danmark" data-relevancy-booster="1.5">Denmark</option><option value="Djibouti" data-alternative-spellings="DJ جيبوتي‎ Jabuuti Gabuuti">Djibouti</option><option value="Dominica" data-alternative-spellings="DM Dominique" data-relevancy-booster="0.5">Dominica</option><option value="Dominican Republic" data-alternative-spellings="DO">Dominican Republic</option><option value="Ecuador" data-alternative-spellings="EC">Ecuador</option><option value="Egypt" data-alternative-spellings="EG" data-relevancy-booster="1.5">Egypt</option><option value="El Salvador" data-alternative-spellings="SV">El Salvador</option><option value="Equatorial Guinea" data-alternative-spellings="GQ">Equatorial Guinea</option><option value="Eritrea" data-alternative-spellings="ER إرتريا ኤርትራ">Eritrea</option><option value="Estonia" data-alternative-spellings="EE Eesti">Estonia</option><option value="Ethiopia" data-alternative-spellings="ET ኢትዮጵያ">Ethiopia</option><option value="Falkland Islands (Malvinas)" data-alternative-spellings="FK" data-relevancy-booster="0.5">Falkland Islands (Malvinas)</option><option value="Faroe Islands" data-alternative-spellings="FO Føroyar Færøerne" data-relevancy-booster="0.5">Faroe Islands</option><option value="Fiji" data-alternative-spellings="FJ Viti फ़िजी">Fiji</option><option value="Finland" data-alternative-spellings="FI Suomi">Finland</option><option value="France" data-alternative-spellings="FR République française" data-relevancy-booster="2.5">France</option><option value="French Guiana" data-alternative-spellings="GF">French Guiana</option><option value="French Polynesia" data-alternative-spellings="PF Polynésie française">French Polynesia</option><option value="French Southern Territories" data-alternative-spellings="TF">French Southern Territories</option><option value="Gabon" data-alternative-spellings="GA République Gabonaise">Gabon</option><option value="Gambia" data-alternative-spellings="GM">Gambia</option><option value="Georgia" data-alternative-spellings="GE საქართველო">Georgia</option><option value="Ghana" data-alternative-spellings="GH">Ghana</option><option value="Gibraltar" data-alternative-spellings="GI" data-relevancy-booster="0.5">Gibraltar</option><option value="Greece" data-alternative-spellings="GR Ελλάδα" data-relevancy-booster="1.5">Greece</option><option value="Greenland" data-alternative-spellings="GL grønland" data-relevancy-booster="0.5">Greenland</option><option value="Grenada" data-alternative-spellings="GD">Grenada</option><option value="Guadeloupe" data-alternative-spellings="GP">Guadeloupe</option><option value="Guam" data-alternative-spellings="GU">Guam</option><option value="Guatemala" data-alternative-spellings="GT">Guatemala</option><option value="Guernsey" data-alternative-spellings="GG" data-relevancy-booster="0.5">Guernsey</option><option value="Guinea" data-alternative-spellings="GN">Guinea</option><option value="Guinea-Bissau" data-alternative-spellings="GW">Guinea-Bissau</option><option value="Guyana" data-alternative-spellings="GY">Guyana</option><option value="Haiti" data-alternative-spellings="HT">Haiti</option><option value="Heard Island and McDonald Islands" data-alternative-spellings="HM">Heard Island and McDonald Islands</option><option value="Holy See (Vatican City State)" data-alternative-spellings="VA" data-relevancy-booster="0.5">Holy See (Vatican City State)</option><option value="Honduras" data-alternative-spellings="HN">Honduras</option><option value="Hong Kong" data-alternative-spellings="HK 香港">Hong Kong</option><option value="Hungary" data-alternative-spellings="HU Magyarország">Hungary</option><option value="Iceland" data-alternative-spellings="IS Island">Iceland</option><option value="India" data-alternative-spellings="IN भारत गणराज्य Hindustan" data-relevancy-booster="3">India</option><option value="Indonesia" data-alternative-spellings="ID" data-relevancy-booster="2">Indonesia</option><option value="Iran, Islamic Republic of" data-alternative-spellings="IR ایران">Iran, Islamic Republic of</option><option value="Iraq" data-alternative-spellings="IQ العراق‎">Iraq</option><option value="Ireland" data-alternative-spellings="IE Éire" data-relevancy-booster="1.2">Ireland</option><option value="Isle of Man" data-alternative-spellings="IM" data-relevancy-booster="0.5">Isle of Man</option><option value="Israel" data-alternative-spellings="IL إسرائيل ישראל">Israel</option><option value="Italy" data-alternative-spellings="IT Italia" data-relevancy-booster="2">Italy</option><option value="Jamaica" data-alternative-spellings="JM">Jamaica</option><option value="Japan" data-alternative-spellings="JP Nippon Nihon 日本" data-relevancy-booster="2.5">Japan</option><option value="Jersey" data-alternative-spellings="JE" data-relevancy-booster="0.5">Jersey</option><option value="Jordan" data-alternative-spellings="JO الأردن">Jordan</option><option value="Kazakhstan" data-alternative-spellings="KZ Қазақстан Казахстан">Kazakhstan</option><option value="Kenya" data-alternative-spellings="KE">Kenya</option><option value="Kiribati" data-alternative-spellings="KI">Kiribati</option><option value="Korea, Democratic People\'s Republic of" data-alternative-spellings="KP North Korea">Korea, Democratic People\'s Republic of</option><option value="Korea, Republic of" data-alternative-spellings="KR South Korea" data-relevancy-booster="1.5">Korea, Republic of</option><option value="Kuwait" data-alternative-spellings="KW الكويت">Kuwait</option><option value="Kyrgyzstan" data-alternative-spellings="KG Кыргызстан">Kyrgyzstan</option><option value="Lao People\'s Democratic Republic" data-alternative-spellings="LA">Lao People\'s Democratic Republic</option><option value="Latvia" data-alternative-spellings="LV Latvija">Latvia</option><option value="Lebanon" data-alternative-spellings="LB لبنان">Lebanon</option><option value="Lesotho" data-alternative-spellings="LS">Lesotho</option><option value="Liberia" data-alternative-spellings="LR">Liberia</option><option value="Libyan Arab Jamahiriya" data-alternative-spellings="LY ليبيا">Libyan Arab Jamahiriya</option><option value="Liechtenstein" data-alternative-spellings="LI">Liechtenstein</option><option value="Lithuania" data-alternative-spellings="LT Lietuva">Lithuania</option><option value="Luxembourg" data-alternative-spellings="LU">Luxembourg</option><option value="Macao" data-alternative-spellings="MO">Macao</option><option value="Macedonia, The Former Yugoslav Republic Of" data-alternative-spellings="MK Македонија">Macedonia, The Former Yugoslav Republic Of</option><option value="Madagascar" data-alternative-spellings="MG Madagasikara">Madagascar</option><option value="Malawi" data-alternative-spellings="MW">Malawi</option><option value="Malaysia" data-alternative-spellings="MY">Malaysia</option><option value="Maldives" data-alternative-spellings="MV">Maldives</option><option value="Mali" data-alternative-spellings="ML">Mali</option><option value="Malta" data-alternative-spellings="MT">Malta</option><option value="Marshall Islands" data-alternative-spellings="MH" data-relevancy-booster="0.5">Marshall Islands</option><option value="Martinique" data-alternative-spellings="MQ">Martinique</option><option value="Mauritania" data-alternative-spellings="MR الموريتانية">Mauritania</option><option value="Mauritius" data-alternative-spellings="MU">Mauritius</option><option value="Mayotte" data-alternative-spellings="YT">Mayotte</option><option value="Mexico" data-alternative-spellings="MX Mexicanos" data-relevancy-booster="1.5">Mexico</option><option value="Micronesia, Federated States of" data-alternative-spellings="FM">Micronesia, Federated States of</option><option value="Moldova, Republic of" data-alternative-spellings="MD">Moldova, Republic of</option><option value="Monaco" data-alternative-spellings="MC">Monaco</option><option value="Mongolia" data-alternative-spellings="MN Mongγol ulus Монгол улс">Mongolia</option><option value="Montenegro" data-alternative-spellings="ME">Montenegro</option><option value="Montserrat" data-alternative-spellings="MS" data-relevancy-booster="0.5">Montserrat</option><option value="Morocco" data-alternative-spellings="MA المغرب">Morocco</option><option value="Mozambique" data-alternative-spellings="MZ Moçambique">Mozambique</option><option value="Myanmar" data-alternative-spellings="MM">Myanmar</option><option value="Namibia" data-alternative-spellings="NA Namibië">Namibia</option><option value="Nauru" data-alternative-spellings="NR Naoero" data-relevancy-booster="0.5">Nauru</option><option value="Nepal" data-alternative-spellings="NP नेपाल">Nepal</option><option value="Netherlands" data-alternative-spellings="NL Holland Nederland" data-relevancy-booster="1.5">Netherlands</option><option value="New Caledonia" data-alternative-spellings="NC" data-relevancy-booster="0.5">New Caledonia</option><option value="New Zealand" data-alternative-spellings="NZ Aotearoa">New Zealand</option><option value="Nicaragua" data-alternative-spellings="NI">Nicaragua</option><option value="Niger" data-alternative-spellings="NE Nijar">Niger</option><option value="Nigeria" data-alternative-spellings="NG Nijeriya Naíjíríà" data-relevancy-booster="1.5">Nigeria</option><option value="Niue" data-alternative-spellings="NU" data-relevancy-booster="0.5">Niue</option><option value="Norfolk Island" data-alternative-spellings="NF" data-relevancy-booster="0.5">Norfolk Island</option><option value="Northern Mariana Islands" data-alternative-spellings="MP" data-relevancy-booster="0.5">Northern Mariana Islands</option><option value="Norway" data-alternative-spellings="NO Norge Noreg" data-relevancy-booster="1.5">Norway</option><option value="Oman" data-alternative-spellings="OM عمان">Oman</option><option value="Pakistan" data-alternative-spellings="PK پاکستان" data-relevancy-booster="2">Pakistan</option><option value="Palau" data-alternative-spellings="PW" data-relevancy-booster="0.5">Palau</option><option value="Palestinian Territory, Occupied" data-alternative-spellings="PS فلسطين">Palestinian Territory, Occupied</option><option value="Panama" data-alternative-spellings="PA">Panama</option><option value="Papua New Guinea" data-alternative-spellings="PG">Papua New Guinea</option><option value="Paraguay" data-alternative-spellings="PY">Paraguay</option><option value="Peru" data-alternative-spellings="PE">Peru</option><option value="Philippines" data-alternative-spellings="PH Pilipinas" data-relevancy-booster="1.5">Philippines</option><option value="Pitcairn" data-alternative-spellings="PN" data-relevancy-booster="0.5">Pitcairn</option><option value="Poland" data-alternative-spellings="PL Polska" data-relevancy-booster="1.25">Poland</option><option value="Portugal" data-alternative-spellings="PT Portuguesa" data-relevancy-booster="1.5">Portugal</option><option value="Puerto Rico" data-alternative-spellings="PR">Puerto Rico</option><option value="Qatar" data-alternative-spellings="QA قطر">Qatar</option><option value="Réunion" data-alternative-spellings="RE Reunion">Réunion</option><option value="Romania" data-alternative-spellings="RO Rumania Roumania România">Romania</option><option value="Russian Federation" data-alternative-spellings="RU Rossiya Российская Россия" data-relevancy-booster="2.5">Russian Federation</option><option value="Rwanda" data-alternative-spellings="RW">Rwanda</option><option value="Saint Barthélemy" data-alternative-spellings="BL St. Barthelemy">Saint Barthélemy</option><option value="Saint Helena" data-alternative-spellings="SH St.">Saint Helena</option><option value="Saint Kitts and Nevis" data-alternative-spellings="KN St.">Saint Kitts and Nevis</option><option value="Saint Lucia" data-alternative-spellings="LC St.">Saint Lucia</option><option value="Saint Martin (French Part)" data-alternative-spellings="MF St.">Saint Martin (French Part)</option><option value="Saint Pierre and Miquelon" data-alternative-spellings="PM St.">Saint Pierre and Miquelon</option><option value="Saint Vincent and the Grenadines" data-alternative-spellings="VC St.">Saint Vincent and the Grenadines</option><option value="Samoa" data-alternative-spellings="WS">Samoa</option><option value="San Marino" data-alternative-spellings="SM">San Marino</option><option value="Sao Tome and Principe" data-alternative-spellings="ST">Sao Tome and Principe</option><option value="Saudi Arabia" data-alternative-spellings="SA السعودية">Saudi Arabia</option><option value="Senegal" data-alternative-spellings="SN Sénégal">Senegal</option><option value="Serbia" data-alternative-spellings="RS Србија Srbija">Serbia</option><option value="Seychelles" data-alternative-spellings="SC" data-relevancy-booster="0.5">Seychelles</option><option value="Sierra Leone" data-alternative-spellings="SL">Sierra Leone</option><option value="Singapore" data-alternative-spellings="SG Singapura  சிங்கப்பூர் குடியரசு 新加坡共和国">Singapore</option><option value="Sint Maarten (Dutch Part)" data-alternative-spellings="SX">Sint Maarten (Dutch Part)</option><option value="Slovakia" data-alternative-spellings="SK Slovenská Slovensko">Slovakia</option><option value="Slovenia" data-alternative-spellings="SI Slovenija">Slovenia</option><option value="Solomon Islands" data-alternative-spellings="SB">Solomon Islands</option><option value="Somalia" data-alternative-spellings="SO الصومال">Somalia</option><option value="South Africa" data-alternative-spellings="ZA RSA Suid-Afrika">South Africa</option><option value="South Georgia and the South Sandwich Islands" data-alternative-spellings="GS">South Georgia and the South Sandwich Islands</option><option value="South Sudan" data-alternative-spellings="SS">South Sudan</option><option value="Spain" data-alternative-spellings="ES España" data-relevancy-booster="2">Spain</option><option value="Sri Lanka" data-alternative-spellings="LK ශ්‍රී ලංකා இலங்கை Ceylon">Sri Lanka</option><option value="Sudan" data-alternative-spellings="SD السودان">Sudan</option><option value="Suriname" data-alternative-spellings="SR शर्नम् Sarnam Sranangron">Suriname</option><option value="Svalbard and Jan Mayen" data-alternative-spellings="SJ" data-relevancy-booster="0.5">Svalbard and Jan Mayen</option><option value="Swaziland" data-alternative-spellings="SZ weSwatini Swatini Ngwane">Swaziland</option><option value="Sweden" data-alternative-spellings="SE Sverige" data-relevancy-booster="1.5">Sweden</option><option value="Switzerland" data-alternative-spellings="CH Swiss Confederation Schweiz Suisse Svizzera Svizra" data-relevancy-booster="1.5">Switzerland</option><option value="Syrian Arab Republic" data-alternative-spellings="SY Syria سورية">Syrian Arab Republic</option><option value="Taiwan, Province of China" data-alternative-spellings="TW 台灣 臺灣">Taiwan, Province of China</option><option value="Tajikistan" data-alternative-spellings="TJ Тоҷикистон Toçikiston">Tajikistan</option><option value="Tanzania, United Republic of" data-alternative-spellings="TZ">Tanzania, United Republic of</option><option value="Thailand" data-alternative-spellings="TH ประเทศไทย Prathet Thai">Thailand</option><option value="Timor-Leste" data-alternative-spellings="TL">Timor-Leste</option><option value="Togo" data-alternative-spellings="TG Togolese">Togo</option><option value="Tokelau" data-alternative-spellings="TK" data-relevancy-booster="0.5">Tokelau</option><option value="Tonga" data-alternative-spellings="TO">Tonga</option><option value="Trinidad and Tobago" data-alternative-spellings="TT">Trinidad and Tobago</option><option value="Tunisia" data-alternative-spellings="TN تونس">Tunisia</option><option value="Turkey" data-alternative-spellings="TR Türkiye Turkiye">Turkey</option><option value="Turkmenistan" data-alternative-spellings="TM Türkmenistan">Turkmenistan</option><option value="Turks and Caicos Islands" data-alternative-spellings="TC" data-relevancy-booster="0.5">Turks and Caicos Islands</option><option value="Tuvalu" data-alternative-spellings="TV" data-relevancy-booster="0.5">Tuvalu</option><option value="Uganda" data-alternative-spellings="UG">Uganda</option><option value="Ukraine" data-alternative-spellings="UA Ukrayina Україна">Ukraine</option><option value="United Arab Emirates" data-alternative-spellings="AE UAE الإمارات">United Arab Emirates</option><option value="United States Minor Outlying Islands" data-alternative-spellings="UM">United States Minor Outlying Islands</option><option value="Uruguay" data-alternative-spellings="UY">Uruguay</option><option value="Uzbekistan" data-alternative-spellings="UZ Ўзбекистон O\'zbekstan O‘zbekiston">Uzbekistan</option><option value="Vanuatu" data-alternative-spellings="VU">Vanuatu</option><option value="Venezuela" data-alternative-spellings="VE">Venezuela</option><option value="Vietnam" data-alternative-spellings="VN Việt Nam" data-relevancy-booster="1.5">Vietnam</option><option value="Virgin Islands, British" data-alternative-spellings="VG" data-relevancy-booster="0.5">Virgin Islands, British</option><option value="Virgin Islands, U.S." data-alternative-spellings="VI" data-relevancy-booster="0.5">Virgin Islands, U.S.</option><option value="Wallis and Futuna" data-alternative-spellings="WF" data-relevancy-booster="0.5">Wallis and Futuna</option><option value="Western Sahara" data-alternative-spellings="EH لصحراء الغربية">Western Sahara</option><option value="Yemen" data-alternative-spellings="YE اليمن">Yemen</option><option value="Zambia" data-alternative-spellings="ZM">Zambia</option><option value="Zimbabwe" data-alternative-spellings="ZW">Zimbabwe</option>')
        }
    };

</script>


<script>

    (function ($) {
        var settings = {
            'sort': !1,
            'sort-attr': 'data-priority',
            'sort-desc': !1,
            'autoselect': !0,
            'alternative-spellings': !0,
            'alternative-spellings-attr': 'data-alternative-spellings',
            'remove-valueless-options': !0,
            'copy-attributes-to-text-field': !0,
            'autocomplete-plugin': 'jquery_ui',
            'relevancy-sorting': !0,
            'relevancy-sorting-partial-match-value': 1,
            'relevancy-sorting-strict-match-value': 5,
            'relevancy-sorting-booster-attr': 'data-relevancy-booster',
            'minLength': 0,
            'delay': 0,
            'autoFocus': !0,
            handle_invalid_input: function (context) {
                var selected_finder = 'option:selected:first';
                if (context.settings['remove-valueless-options']) {
                    selected_finder = 'option:selected[value!=""]:first'
                }
                context.$text_field.val(context.$select_field.find(selected_finder).text())
            },
            handle_select_field: function ($select_field) {
                return $select_field.hide()
            },
            insert_text_field: function (context) {
                var $text_field = $('<input type="text"></input>');
                if (settings['copy-attributes-to-text-field']) {
                    var attrs = {};
                    var raw_attrs = context.$select_field[0].attributes;
                    for (var i = 0; i < raw_attrs.length; i++) {
                        var key = raw_attrs[i].nodeName;
                        var value = raw_attrs[i].nodeValue;
                        if (key !== 'name' && key !== 'id' && typeof context.$select_field.attr(key) !== 'undefined') {
                            attrs[key] = value
                        }
                    }
                    ;$text_field.attr(attrs)
                }
                $text_field.blur(function () {
                    var valid_values = context.$select_field.find('option').map(function (i, option) {
                        return $(option).text()
                    });
                    if (($.inArray($text_field.val(), valid_values) < 0) && typeof settings.handle_invalid_input === 'function') {
                        settings.handle_invalid_input(context)
                    }
                });
                if (context.settings.autoselect) {
                    $text_field.click(function () {
                        this.select()
                    })
                }
                var selected_finder = 'option:selected:first';
                if (context.settings['remove-valueless-options']) {
                    selected_finder = 'option:selected[value!=""]:first'
                }
                return $text_field.val(context.$select_field.find(selected_finder).text()).insertAfter(context.$select_field)
            },
            extract_options: function ($select_field) {
                var options = [];
                var $options = $select_field.find('option');
                var number_of_options = $options.length;
                $options.each(function () {
                    var $option = $(this);
                    var option = {'real-value': $option.attr('value'), 'label': $option.text()}
                    if (settings['remove-valueless-options'] && option['real-value'] === '') {
                    } else {
                        option.matches = option.label;
                        var alternative_spellings = $option.attr(settings['alternative-spellings-attr']);
                        if (alternative_spellings) {
                            option.matches += ' ' + alternative_spellings
                        }
                        if (settings.sort) {
                            var weight = parseInt($option.attr(settings['sort-attr']), 10);
                            if (weight) {
                                option.weight = weight
                            } else {
                                option.weight = number_of_options
                            }
                        }
                        if (settings['relevancy-sorting']) {
                            option['relevancy-score'] = 0;
                            option['relevancy-score-booster'] = 1;
                            var boost_by = parseFloat($option.attr(settings['relevancy-sorting-booster-attr']));
                            if (boost_by) {
                                option['relevancy-score-booster'] = boost_by
                            }
                        }
                        options.push(option)
                    }
                });
                if (settings.sort) {
                    if (settings['sort-desc']) {
                        options.sort(function (a, b) {
                            return b.weight - a.weight
                        })
                    } else {
                        options.sort(function (a, b) {
                            return a.weight - b.weight
                        })
                    }
                }
                return options
            }
        };
        var public_methods = {
            init: function (customizations) {
                if (/msie/.test(navigator.userAgent.toLowerCase()) && parseInt(navigator.appVersion, 10) <= 6) {
                    return this
                } else {
                    settings = $.extend(settings, customizations);
                    return this.each(function () {
                        var $select_field = $(this);
                        var context = {
                            '$select_field': $select_field,
                            'options': settings.extract_options($select_field),
                            'settings': settings
                        };
                        context['$text_field'] = settings.insert_text_field(context);
                        settings.handle_select_field($select_field);
                        if (typeof settings['autocomplete-plugin'] === 'string') {
                            adapters[settings['autocomplete-plugin']](context)
                        } else {
                            settings['autocomplete-plugin'](context)
                        }
                    })
                }
            }
        };
        var adapters = {
            jquery_ui: function (context) {
                var filter_options = function (term) {
                    var split_term = term.split(' ');
                    var matchers = [];
                    for (var i = 0; i < split_term.length; i++) {
                        if (split_term[i].length > 0) {
                            var matcher = {};
                            matcher.partial = new RegExp($.ui.autocomplete.escapeRegex(split_term[i]), "i");
                            if (context.settings['relevancy-sorting']) {
                                matcher.strict = new RegExp("^" + $.ui.autocomplete.escapeRegex(split_term[i]), "i")
                            }
                            matchers.push(matcher)
                        }
                    }
                    ;
                    return $.grep(context.options, function (option) {
                        var partial_matches = 0;
                        if (context.settings['relevancy-sorting']) {
                            var strict_match = !1;
                            var split_option_matches = option.matches.split(' ')
                        }
                        for (var i = 0; i < matchers.length; i++) {
                            if (matchers[i].partial.test(option.matches)) {
                                partial_matches++
                            }
                            if (context.settings['relevancy-sorting']) {
                                for (var q = 0; q < split_option_matches.length; q++) {
                                    if (matchers[i].strict.test(split_option_matches[q])) {
                                        strict_match = !0;
                                        break
                                    }
                                }
                            }
                        }
                        ;
                        if (context.settings['relevancy-sorting']) {
                            var option_score = 0;
                            option_score += partial_matches * context.settings['relevancy-sorting-partial-match-value'];
                            if (strict_match) {
                                option_score += context.settings['relevancy-sorting-strict-match-value']
                            }
                            option_score = option_score * option['relevancy-score-booster'];
                            option['relevancy-score'] = option_score
                        }
                        return (!term || matchers.length === partial_matches)
                    })
                }
                var update_select_value = function (option) {
                    if (option) {
                        if (context.$select_field.val() !== option['real-value']) {
                            context.$select_field.val(option['real-value']);
                            context.$select_field.change()
                        }
                    } else {
                        var option_name = context.$text_field.val().toLowerCase();
                        var matching_option = {'real-value': !1};
                        for (var i = 0; i < context.options.length; i++) {
                            if (option_name === context.options[i].label.toLowerCase()) {
                                matching_option = context.options[i];
                                break
                            }
                        }
                        ;
                        if (context.$select_field.val() !== matching_option['real-value']) {
                            context.$select_field.val(matching_option['real-value'] || '');
                            context.$select_field.change()
                        }
                        if (matching_option['real-value']) {
                            context.$text_field.val(matching_option.label)
                        }
                        if (typeof context.settings.handle_invalid_input === 'function' && context.$select_field.val() === '') {
                            context.settings.handle_invalid_input(context)
                        }
                    }
                }
                context.$text_field.autocomplete({
                    'minLength': context.settings.minLength,
                    'delay': context.settings.delay,
                    'autoFocus': context.settings.autoFocus,
                    source: function (request, response) {
                        var filtered_options = filter_options(request.term);
                        if (context.settings['relevancy-sorting']) {
                            filtered_options = filtered_options.sort(function (a, b) {
                                if (b['relevancy-score'] == a['relevancy-score']) {
                                    return b.label < a.label ? 1 : -1
                                } else {
                                    return b['relevancy-score'] - a['relevancy-score']
                                }
                            })
                        }
                        response(filtered_options)
                    },
                    select: function (event, ui) {
                        update_select_value(ui.item)
                    },
                    change: function (event, ui) {
                        update_select_value(ui.item)
                    }
                });
                context.$text_field.parents('form:first').submit(function () {
                    update_select_value()
                });
                update_select_value()
            }
        };
        $.fn.selectToAutocomplete = function (method) {
            if (public_methods[method]) {
                return public_methods[method].apply(this, Array.prototype.slice.call(arguments, 1))
            } else if (typeof method === 'object' || !method) {
                return public_methods.init.apply(this, arguments)
            } else {
                $.error('Method ' + method + ' does not exist on jQuery.fn.selectToAutocomplete')
            }
        }
    })(jQuery);

    translatePage();
</script>


<script>
    var NIXValidator, language;

    NIXValidator = {};

    language = (Cookies.get('lang')) ? Cookies.get('lang') : 'en_US';


    var USER_LANGUAGE = {
        'en_US': {
            'reset': 'Reset',
            'please_enter_your': 'Please enter your ',
            'please_enter_your_email': 'Please enter your email address',
            'creating_account': 'Creating account ...',
            'create_account_btn': 'Create Account',
            'loggin_in': 'Logging you in...',
            'login': 'Login',
            'email_dont_exist': 'This email does not exist',
            'username_dont_exist': 'This username does not exist',
            'valid_email': 'Please enter a valid email address',
            'check_credentials': 'Please use your username and password',
            'you_must_agree': 'Please agree to the Privacy Policy and Terms of Service',
            'first_name': 'First Name',
            'last_name': 'Last Name',
            'max30': 'Your #[field] is too long (Max. 30 characters)',
            'noURL': 'Your #[field] cannot contain URL',
            'noSymbols': 'Your #[field] cannot contain symbols: &/:$%<>',
            'email_used': 'This email is already used',
            'username_taken': 'This username is already taken',
            'enter_username': 'Please enter a username',
            'enter_valid_username': 'Please enter a valid username (Min. 4 characters, a-z A-Z 0-9)',
            'username_too_long': 'Your username is too long (Max. 240 characters)',
            'short_password': 'Password is too short (Min. 6 characters)',
            'no_match': 'Passwords do not match',
            'enter_password': 'Please enter a password',
            'unexpected_error': 'Sorry, there was an unexpected error. Please try again.',
            'invalid_token': 'Invalid verification token.',
            'processing': 'Processing...',
            'user_not_found': 'User not found',
            'login_error_max_rate_1': 'You are allowed a maximum ',
            'login_error_max_rate_2': ' request rate, please try again later.',
            'login_too_many_attempts_1': 'Too many log in attempts. Please Reset Password or retry in ',
            'login_too_many_attempts_2': ' minutes.'
        },
        'de_DE': {
            'reset': 'Zurücksetzen',
            'please_enter_your': 'Bitte geben Sie ihren ',
            'please_enter_your_email': 'Bitte geben Sie Ihre Email-Adresse an',
            'creating_account': 'Erstellen von Ihrem Konto ...',
            'create_account_btn': 'Konto erstellen',
            'loggin_in': 'Einloggen...',
            'login': 'Anmelden',
            'email_dont_exist': 'Diese E-Mail existiert nicht',
            'username_dont_exist': 'Dieser Benutzername existiert nicht',
            'valid_email': 'Bitte geben Sie eine gültige E-Mail-Adresse ein',
            'check_credentials': 'Bitte benutzen Sie Ihren Benutzernamen und Ihr Passwort',
            'you_must_agree': 'Bitte stimmen Sie den Datenschutzbestimmungen und Nutzungsbedingungen zu',
            'first_name': 'Vorname',
            'last_name': 'Nachname',
            'max30': 'Dein #[field] ist zu lang (max. 30 Zeichen)',
            'noURL': 'Ihr #[field] darf keine URL enthalten',
            'noSymbols': 'Ihr #[field] darf keine Symbole enthalten: & /: $% <>',
            'email_used': 'Diese E-Mail wird bereits verwendet',
            'username_taken': 'Dieser Benutzername ist bereits vergeben',
            'enter_username': 'Bitte geben Sie einen Benutzernamen ein',
            'enter_valid_username': 'Bitte geben Sie einen gültigen Benutzername an (Minimum 4 Zeichen, a-z A-Z 0-9)',
            'username_too_long': 'Ihr Benutzername ist zu lang (max. 240 Zeichen)',
            'short_password': 'Das Passwort ist zu kurz (Minimum 6 Zeichen)',
            'no_match': 'Passwörter stimmen nicht überein',
            'enter_password': 'Bitte Passwort eingeben',
            'unexpected_error': 'Entschuldigung, es ist ein unerwarteter Fehler aufgetreten. Bitte versuche es erneut.',
            'invalid_token': 'Ungültiges Bestätigungstoken.',
            'processing': 'In Bearbeitung ...',
            'user_not_found': 'Benutzer wurde nicht gefunden',
            'login_error_max_rate_1': 'Sie dürfen maximal ',
            'login_error_max_rate_2': ' Anfragen stellen. Bitte versuchen Sie es später erneut.',
            'login_too_many_attempts_1': 'Zu viele Anmeldeversuche. Bitte setzen Sie das Passwort zurück oder versuchen Sie es in ',
            'login_too_many_attempts_2': ' Minuten erneut.'
        },
        'ja_JP': {
            "reset": "リセット",
            "please_enter_your": "入力してください",
            "please_enter_your_email": "電子メールアドレスを入力してください",
            "creating_account": "アカウント作成中...",
            "create_account_btn": "アカウント作成",
            "loggin_in": "ログインします...",
            "login": "ログイン",
            "email_dont_exist": "この電子メールは存在しません",
            "username_dont_exist": "このユーザー名は存在しません",
            "valid_email": "有効な電子メールアドレスを入力してください",
            "check_credentials": "あなたのユーザー名とパスワードを使用してください",
            "you_must_agree": "プライバシーポリシーと利用規約に同意してください",
            "first_name": "名前",
            "last_name": "名字",
            "max30": "#[field]が長すぎます（最大30文字）",
            "noURL": "#[field]にURLを含んではいけません",
            "noSymbols": "#[field]に含んではいけない記号：&/:$%<>",
            "email_used": "この電子メールは既に使用されています",
            "username_taken": "このユーザー名は既に使用されています",
            "enter_username": "ユーザー名を入力してください",
            "enter_valid_username": "有効なユーザー名を入力してください（最低4文字：a～z、A～Z、0～9）",
            "username_too_long": "ユーザー名が長すぎます（最大240文字）",
            "short_password": "パスワードが短すぎます（最小6文字）",
            "no_match": "パスワードが一致しません",
            "enter_password": "パスワードを入力してください",
            "unexpected_error": "申し訳ありません。予期せぬエラーが発生しました。もう一度やり直してください。",
            "invalid_token": "無効な認証トークンです。",
            "processing": "処理中です...",
            "user_not_found": "ユーザーが見つかりません",
            'login_error_max_rate_1': '許可されているリクエストレートは最大',
            'login_error_max_rate_2': 'です。後でもう一度やり直してください。',
            'login_too_many_attempts_1': 'ログイン試行が多すぎます。 パスワードをリセットするか、',
            'login_too_many_attempts_2': '分後に再試行してください。'
        },
        'fr_FR': {
            "reset": "Réinitialiser",
            "please_enter_your": "Veuillez saisir votre",
            "please_enter_your_email": "Veuillez saisir votre adresse e-mail.",
            "creating_account": "Création du compte…",
            "create_account_btn": "Créer mon compte",
            "loggin_in": "Connexion…",
            "login": "Se connecter",
            "email_dont_exist": "Cette adresse e-mail n'existe pas.",
            "username_dont_exist": "Ce nom d'utilisateur n'existe pas.",
            "valid_email": "Veuillez saisir une adresse e-mail valide.",
            "check_credentials": "Veuillez utiliser vos nom d'utilisateur et mot de passe.",
            "you_must_agree": "Veuillez accepter la Politique de confidentialité et les Conditions d'utilisation.",
            "first_name": "Prénom",
            "last_name": "Nom",
            "max30": "Votre #[field] est trop long (maximum 30 caractères).",
            "noURL": "Votre #[field] ne peut pas contenir d'URL.",
            "noSymbols": "Votre #[field] ne peut pas contenir ces symboles : &/:$%<>",
            "email_used": "Cette adresse e-mail est déjà utilisée.",
            "username_taken": "Ce nom d'utilisateur est déjà pris.",
            "enter_username": "Veuillez saisir un nom d'utilisateur.",
            "enter_valid_username": "Veuillez saisir un nom d'utilisateur valide (minimum 4 caractères, a-z A-Z 0-9).",
            "username_too_long": "Votre nom d'utilisateur est trop long (maximum 240 caractères).",
            "short_password": "Votre mot de passe est trop court (minimum 6 caractères).",
            "no_match": "Les mots de passe ne correspondent pas.",
            "enter_password": "Veuillez saisir un mot de passe.",
            "unexpected_error": "Désolé, une erreur inattendue est survenue. Veuillez réessayer.",
            "invalid_token": "Code de vérification invalide",
            "processing": "Traitement…",
            "user_not_found": "Utilisateur introuvable",
            'login_error_max_rate_1': 'Vous avez droit à un maximum',
            'login_error_max_rate_2': 'taux de demande, veuillez réessayer plus tard.',
            'login_too_many_attempts_1': 'Trop de tentatives de connexion. Veuillez réinitialiser le mot de passe ou réessayer dans ',
            'login_too_many_attempts_2': 'minutes.'
        },
    };

    (function () {
        var EMAIL_REGEXP, SYMBOL_REGEXP, UAstring, URL_REGEXP, browser, browserVer, browsers, data, index, rv, _i, _len;
        EMAIL_REGEXP = /^[_a-z0-9-]+([\.\+][_a-z0-9-]+)*@(?!myemokili\.com$)([a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$)/i;
        URL_REGEXP = /([a-zA-Z\d]+:\/\/)?((\w+:\w+@)?([a-zA-Z\d.-]+\.[A-Za-z]{2,4})(:\d+)?(\/.*)?)/i;
        SYMBOL_REGEXP = /[&/:$%<>]/;
        browsers = [
            {
                key: 'Edge',
                identity: 'MS Edge'
            }, {
                key: 'Chrome',
                identity: 'Chrome'
            }, {
                key: 'MSIE',
                identity: 'Explorer'
            }, {
                key: 'Trident',
                identity: 'Explorer'
            }, {
                key: 'Firefox',
                identity: 'Firefox'
            }, {
                key: 'Safari',
                identity: 'Safari'
            }, {
                key: 'Opera',
                identity: 'Opera'
            }
        ];
        browser = 'Other';
        browserVer = 'Unknown';
        UAstring = navigator.userAgent;
        for (_i = 0, _len = browsers.length; _i < _len; _i++) {
            data = browsers[_i];
            index = UAstring.indexOf(data.key);
            if (index !== -1) {
                browser = data.identity;
                rv = UAstring.indexOf('rv:');
                if (data.key === 'Trident' && rv !== -1) {
                    browserVer = parseFloat(UAstring.substring(rv + 3));
                } else {
                    browserVer = parseFloat(UAstring.substring(index + data.key.length + 1));
                }
                break;
            }
        }
        return NIXValidator = {
            name: function (name, text) {
                if (text == null) {
                    text = 'name';
                }
                return Q.fcall(function () {
                    name = $.trim(name);
                    var error;
                    if (name.length === 0) {
                        throw  USER_LANGUAGE[language]['please_enter_your'] + text;
                    }
                    if (name.length > 30) {
                        error = USER_LANGUAGE[language]['max30'].replace('#[field]', text.toLowerCase())
                        throw error;
                    }
                    if (URL_REGEXP.test(name)) {
                        error = USER_LANGUAGE[language]['noURL'].replace('#[field]', text.toLowerCase())
                        throw error;
                    }
                    if (SYMBOL_REGEXP.test(name)) {
                        error = USER_LANGUAGE[language]['noSymbols'].replace('#[field]', text.toLowerCase())
                        throw error;
                    }
                });
            },
            email: function (email) {
                return Q.fcall(function () {
                    var deferred;
                    email = $.trim(email);
                    if (email.length === 0) {
                        throw USER_LANGUAGE[language]['please_enter_your_email'];
                    }
                    if (!EMAIL_REGEXP.test(email)) {
                        throw USER_LANGUAGE[language]['valid_email'];
                    }
                    deferred = Q.defer();
                    $.ajax({
                        url: "" + apiUrl + "/user/exists/json/",
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            email: email,
                            username: 'emokili@' + usernameDomainPart
                        },
                        success: function (data) {
                            if (data.email) {
                                return deferred.resolve();
                            }
                            return deferred.reject(USER_LANGUAGE[language]['email_dont_exist']);
                        },
                        error: function (request) {
                            return deferred.reject(new Error(request.responseText));
                        }
                    });
                    return deferred.promise;
                });
            },
            username: function (username) {
                return Q.fcall(function () {
                    var deferred, notusername;
                    username = $.trim(username);
                    if (username.length === 0) {
                        throw  USER_LANGUAGE[language]['enter_username'];
                    }
                    notusername = new RegExp('[^-_.A-Za-z0-9]');
                    if ((username.length < 4) || (username.match(notusername))) {
                        throw USER_LANGUAGE[language]['enter_valid_username'];
                    }
                    if (("" + username + "@myemokili.com").length > 255) {
                        throw USER_LANGUAGE[language]['username_too_long'];
                    }
                    deferred = Q.defer();
                    $.ajax({
                        url: "" + apiUrl + "/user/exists/json/",
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            username: username + '@' + usernameDomainPart,
                            email: 'email@email.com'
                        },
                        success: function (data) {
                            if (data.username) {
                                return deferred.resolve();
                            }
                            return deferred.reject(USER_LANGUAGE[language]['username_dont_exist']);
                        },
                        error: function (request) {
                            return deferred.reject(new Error(request.responseText));
                        }
                    });
                    return deferred.promise;
                });
            },
            password: function (password) {
                return Q.fcall(function () {
                    if (password.length === 0) {
                        throw USER_LANGUAGE[language]['enter_password'];
                    }
                    if (password.length < 6) {
                        throw USER_LANGUAGE[language]['short_password'];
                    }
                });
            },
            password2: function (password, password2) {
                return this.password(password).then(function () {
                    if (password !== password2) {
                        throw USER_LANGUAGE[language]['no_match'];
                    }
                }, function () {
                });
            },
            browser: {
                name: browser,
                version: browserVer,
                supported: !(browser === 'Explorer' && browserVer < 10.0)
            },
            old: {
                isValidSerialNumber: function (param) {
                    var notnumber;
                    notnumber = new RegExp('[^0-9]');
                    if ((param.length < 16) || (param.match(notnumber))) {
                        return false;
                    }
                    return true;
                },
                isValidName: function (param) {
                    if (param.length === 0 || param.length > 30) {
                        return false;
                    }
                    if (URL_REGEXP.test(name)) {
                        return false;
                    }
                    if (SYMBOL_REGEXP.test(name)) {
                        return false;
                    }
                    return true;
                },
                isValidEmail: function (param) {
                    if (EMAIL_REGEXP.test(param)) {
                        return true;
                    }
                    return false;
                },
                isValidNixEmail: function (param) {
                    var notnixemail;
                    notnixemail = new RegExp('[^-_.A-Za-z0-9]');
                    if ((param.length < 4) || (param.match(notnixemail))) {
                        return false;
                    }
                    return true;
                },
                isTooShortNixEmail: function (param) {
                    if (param.length < 4) {
                        return true;
                    }
                    return false;
                },
                isMatchPassword: function (password1, password2) {
                    if (password1 !== password2) {
                        return false;
                    }
                    return true;
                }
            }
        };
    })();
</script>

<script>
    $(document).ready(function () {
        var browserCheck, loginTypeInput, changeTncPopupTab, clearAuthModalClass, clearSignupForm, closeAuthModal,
            closeModalAnimation, loginForm, loginSubmitBtn, loginToken, logoutBtn, openLogin, openModalAnimation,
            openSignup, signupForm, signupInputError, signupNameInvalidInputError, validateSignupEl,
            loginErrorContainer;
        $('#copyright .date').append((new Date()).getFullYear());
        loginForm = $('#login-form');
        loginTypeInput = $('.login-type-input')
        loginErrorContainer = $('.login-error-container');
        logoutBtn = $('#auth-header #logout');
        loginToken = 'emokili.token';
        signupForm = $('#signup-form');
        SelectCountry.init();
        logoutBtn.click(function () {
            sessionStorage.removeItem(loginToken);
            localStorage.removeItem(loginToken);
            return window.location = apiUrl + '/sign_out/';
        });
        loginSubmitBtn = $('#login-form .submit');
        loginForm.on('submit', function () {
            var values;
            $('#login-form ul.error').remove();
            loginTypeInput.removeClass('error')
            values = {};
            $('#login-form input').each(function () {
                if ($(this).attr('type') === 'checkbox') {
                    return values[$(this).attr('name')] = $(this).prop('checked');
                } else {
                    return values[$(this).attr('name')] = $(this).val();
                }
            });
            loginSubmitBtn.addClass('disabled');
            loginSubmitBtn.attr('value', USER_LANGUAGE[language]['loggin_in']);
            loginSubmitBtn.attr('disabled', 'disabled');
            $.ajax({
                url: apiUrl + '/web/login',
                dataType: 'json',
                data: values,
                type: 'POST',
                success: function (data) {
                    var error, errors, idx, message, msg, url, _i, _len, _ref;
                    if (data.code == 200) {
                        if (data.token) {
                            localStorage.setItem(loginToken, data.token);
                            sessionStorage.removeItem(loginToken);
                        }
                        $('#loginRedirectForm input[name="token"]').val(data.token);
                        $('#loginRedirectForm input[name="startPairing"]').val($('#signup_pair_yes').prop('checked'));

                        return $('#loginRedirectForm').submit();
                    } else {
                        sessionStorage.removeItem(loginToken);
                        localStorage.removeItem(loginToken);
                        errors = data.errors;
                        error = $('<ul class="error"/>');
                        if (errors.__all__) {
                            _ref = errors.__all__.messages;
                            for (_i = 0, _len = _ref.length; _i < _len; _i++) {
                                message = _ref[_i];
                                msg = message[0];
                                idx = msg.indexOf(' login via ');

                                if (idx > -1) {
                                    url = msg.slice(idx + 11);
                                    msg = "Please login via <a href='" + url + "'>" + url + "</a>";
                                }

                                idx = msg.indexOf('username and password');
                                if (idx > -1) {
                                    msg = USER_LANGUAGE[language]['check_credentials'];
                                } else if (idk = msg.match(/You are allowed a maximum (.*) request rate, please try again later\./)) {
                                    msg = '' + USER_LANGUAGE[language]['login_error_max_rate_1'] + idk[1] + USER_LANGUAGE[language]['login_error_max_rate_2'];
                                } else if (idk = msg.match(/Too many log in attempts. Please Reset Password or retry in (.*) minutes\./)) {
                                    msg = '' + USER_LANGUAGE[language]['login_too_many_attempts_1'] + idk[1] + USER_LANGUAGE[language]['login_too_many_attempts_2'];
                                }
                                if (msg) {
                                    error.append("<li>" + msg + "</li>");
                                }
                            }
                        }
                        loginTypeInput.addClass('error');
                        return loginErrorContainer.append(error);
                    }
                },
                error: function (request, status, error) {
                    sessionStorage.removeItem(loginToken);
                    localStorage.removeItem(loginToken);
                    return loginErrorContainer.append('<ul class="error"><li>' + USER_LANGUAGE[language]['unexpected_error'] + '</li></ul>');
                },
                complete: function () {
                    loginSubmitBtn.attr('value', USER_LANGUAGE[language]['login']);
                    return loginSubmitBtn.removeClass('disabled').removeAttr('disabled');
                }
            });
            return false;
        });
        clearSignupForm = function () {
            signupForm.find('.input-group').removeClass('error');
            signupForm.find('input[type=text], input[type=password]').val('');
            signupForm.find('input[name=signup_tnc]').removeAttr('checked');
            if ($('#auth-modal').hasClass('with-pairing')) {
                return signupForm.find('#signup_pair_yes').click();
            } else {
                return signupForm.find('#signup_pair_no').click();
            }
        };
        signupInputError = function (el, errorText) {
            el.closest('.input-group').addClass('error');
            return el.siblings('.input-error').children('span').html(errorText);
        };
        signupNameInvalidInputError = function (errorText) {
            var elFirstname, elLastname;
            elFirstname = $('#auth-modal .auth-modal-signup [name=firstname]');
            elLastname = $('#auth-modal .auth-modal-signup [name=lastname]');
            signupInputError(elFirstname, errorText);
            return signupInputError(elLastname, errorText);
        };
        validateSignupEl = function (elName) {
            var el, password, validator;
            el = $("#auth-modal .auth-modal-signup [name=" + elName + "]");
            return validator = ((function () {
                switch (false) {
                    case elName !== 'firstname':
                        return NIXValidator.name(el.val(), USER_LANGUAGE[language]['first_name']);
                    case elName !== 'lastname':
                        return NIXValidator.name(el.val(), USER_LANGUAGE[language]['last_name']);
                    case elName !== 'email':
                        return NIXValidator.email(el.val()).then(function () {
                            throw USER_LANGUAGE[language]['email_used'];
                        }, function (reason) {
                            if (reason.indexOf('not exist') === -1 && reason.indexOf('existiert nicht') === -1 && reason.indexOf('は存在しません') === -1 && reason.indexOf("n'existe pas") === -1) {
                                throw reason;
                            }
                        });
                    case elName !== 'username':
                        return NIXValidator.username(el.val()).then(function () {
                            throw USER_LANGUAGE[language]['username_taken'];
                        }, function (reason) {
                            if (reason.indexOf('not exist') === -1 && reason.indexOf('existiert nicht') === -1 && reason.indexOf('は存在しません') === -1 && reason.indexOf("n'existe pas") === -1) {
                                throw reason;
                            }
                        });
                    case elName !== 'password':
                        return NIXValidator.password(el.val());
                    case elName !== 'password2':
                        password = $('#auth-modal .auth-modal-signup [name=password]').val();
                        return NIXValidator.password2(password, el.val());
                    case elName !== 'signup_tnc':
                        return Q.fcall(function () {
                            if (!el.prop('checked')) {
                                throw USER_LANGUAGE[language]['you_must_agree'];
                            }
                        });
                    default:
                        return Q.fcall(function () {
                            return true;
                        });
                }
            })()).fail(function (reason) {
                signupInputError(el, reason);
                throw reason;
            });
        };
        $('#auth-modal .auth-modal-signup input').on('keydown change', function (event) {
            return $(this).closest('.input-group').removeClass('error');
        });
        $('#auth-modal .auth-modal-signup input[type=text], #auth-modal .auth-modal-signup input[type=password]').on('blur', function (event) {
            $(this).closest('.input-group').removeClass('error');
            $(this).val($.trim($(this).val()));
            return validateSignupEl($(this).attr('name'));
        });
        $('#auth-modal .signup-next').click(function () {
            return Q.all([validateSignupEl('firstname'), validateSignupEl('lastname'), validateSignupEl('email'), validateSignupEl('signup_tnc')]).then(function () {
                var country;
                country = $('#auth-modal .auth-modal-signup input.select_country');
                if (country.val() === '') {
                    country.val('United States');
                }
                signupForm.submit();
                return $('#auth-modal').removeClass('signup-1').addClass('signup-2');
            });
        });
        signupForm.on('submit', function (event) {
            if (getToken) {
                getToken();
            }
            var submitBtn;
            event.preventDefault();
            if (!$('#auth-modal').hasClass('signup-2')) {
                return;
            }
            submitBtn = signupForm.find('.signup_submit');
            submitBtn.closest('.input-group').removeClass('error');
            return Q.all([validateSignupEl('firstname'), validateSignupEl('lastname'), validateSignupEl('email'), validateSignupEl('username'), validateSignupEl('password'), validateSignupEl('password2')]).then(function () {
                var formData;
                formData = {
                    username: signupForm.find('[name=username]').val() + ("@" + usernameDomainPart),
                    password: signupForm.find('[name=password]').val(),
                    firstName: signupForm.find('[name=firstname]').val(),
                    lastName: signupForm.find('[name=lastname]').val(),
                    country: signupForm.find('[name=country]').val(),
                    email: signupForm.find('[name=email]').val(),
                    locale: (/(?:^|; )lang=([^;]*)/g.exec(document.cookie) || [])[1],
                    token: signupForm.find('[name=token]').val(),
                    captcha: document.getElementById('g-recaptcha') ? grecaptcha.getResponse() : '',
                };
                submitBtn.addClass('disabled');
                submitBtn.attr('value', USER_LANGUAGE[language]['creating_account']);
                submitBtn.attr('disabled', 'disabled');
                return $.ajax({
                    url: "" + apiV3Url + "/users/",
                    dataType: 'json',
                    data: formData,
                    type: 'POST',
                    success: function (data) {
                        $('#auth-modal').removeClass('signup-2').addClass('signup-3');
                        $('#login_username').val(formData.username);
                        $('#login_password').val(formData.password);
                        signupForm.find('#signup_pair_no').click();
                        return loginForm.submit();
                    },
                    error: function (request, status, error) {
                        try {
                            grecaptcha.reset()
                        } catch (e) {
                        }
                        if ((request != null) && (request.responseText != null) && request.responseText.startsWith('InvalidFirstNameLastNameError')) {
                            signupNameInvalidInputError(request.responseJSON.error.message);
                            return $('#auth-modal').removeClass('signup-2').addClass('signup-1');
                        } else {
                            return signupInputError(submitBtn, '' + USER_LANGUAGE[language]['unexpected_error'] + '');
                        }
                    },
                    complete: function () {
                        submitBtn.attr('value', USER_LANGUAGE[language]['create_account_btn']);
                        return submitBtn.removeClass('disabled').removeAttr('disabled');
                    }
                });
            });
        });
        browserCheck = function () {
            if (!NIXValidator.browser.supported) {
                closeAuthModal($('#auth-modal'));
                openModalAnimation($('#unsupported-modal'));
                return false;
            } else {
                return true;
            }
        };
        clearAuthModalClass = function () {
            return $('#auth-modal').removeClass('show-login show-signup signup-1 signup-2');
        };
        openModalAnimation = function (modal) {
            modal.addClass('show-modal');
            return setTimeout(function () {
                return modal.addClass('show');
            }, 10);
        };
        closeModalAnimation = function (modal, callback) {
            modal.removeClass('show');
            return setTimeout(function () {
                modal.removeClass('show-modal with-pairing');
                if (typeof callback === 'function') {
                    return callback();
                }
            }, 300);
        };
        closeAuthModal = function (modal) {
            return closeModalAnimation(modal, clearAuthModalClass);
        };
        openLogin = function (openModal) {
            if (openModal == null) {
                openModal = false;
            }
            if (!browserCheck()) {
                return;
            }
            clearSignupForm();
            clearAuthModalClass();
            $('#auth-modal').addClass('show-login');
            if (openModal) {
                openModalAnimation($('#auth-modal'));
            }
            return $('#auth-modal #login_username').focus();
        };
        openSignup = function (pair, openModal) {
            if (pair == null) {
                pair = false;
            }
            if (openModal == null) {
                openModal = false;
            }
            if (!browserCheck()) {
                return;
            }
            if (pair) {
                $('#auth-modal').addClass('with-pairing');
            }
            clearSignupForm();
            clearAuthModalClass();
            $('#auth-modal').addClass('show-signup signup-1');
            if (openModal) {
                openModalAnimation($('#auth-modal'));
            }
            return $('#auth-modal input[name=signup_firstname]').focus();
        };
        changeTncPopupTab = function (href) {
            $('#auth-modal .auth-modal-tnc-tab-btn').removeClass('active');
            $('#auth-modal .auth-modal-tnc-tab').removeClass('active');
            $("#auth-modal .auth-modal-tnc-tab-btn[href=" + href + "]").addClass('active');
            $("#auth-modal " + href + ".auth-modal-tnc-tab").addClass('active');
        };
        $('#login, .open_login').click(function (e) {
            e.preventDefault();
            openLogin(true);
            return ga('send', 'event', 'Click Header', 'login');
        });
        $('#auth-modal .show-login').click(function () {
            return openLogin(false);
        });
        $('#signup').click(function () {
            openSignup(false, true);
            return ga('send', 'event', 'Click Header', 'create account');
        });
        $('#signup-pair').click(function () {
            openSignup(true, true);
            return ga('send', 'event', 'Click Header', 'activate frame');
        });
        $('#auth-modal .show-signup').click(function () {
            return openSignup(false, false);
        });
        $('.auth-modal .auth-modal-close').click(function () {
            return closeAuthModal($(this).closest('.auth-modal'));
        });
        $('#auth-modal .tnc-learn-more').click(function (e) {
            e.preventDefault();
            return openModalAnimation($('#auth-modal-tnc'));
        });
        $('#auth-modal .auth-modal-tnc-tab-btn').click(function (e) {
            e.preventDefault();
            return changeTncPopupTab($(this).attr('href'));
        });
        $('#auth-modal #auth-modal-tnc-action-cancel').click(function (e) {
            return closeModalAnimation($('#auth-modal-tnc'));
        });
        $('#auth-modal #auth-modal-tnc-action-agree').click(function (e) {
            signupForm.find('input[name=signup_tnc]').prop('checked', true);
            return closeModalAnimation($('#auth-modal-tnc'));
        });
        $('#user').click(function () {
            return ga('send', 'event', 'Click Header', "user\'s photos");
        });
        $('#logout').click(function () {
            return ga('send', 'event', 'Click Header', 'logout');
        });
        $('#main-header .nav-item a').click(function () {
            return ga('send', 'event', 'Click Header', $(this).text());
        });
        $('#site-footer .nav-item a').click(function () {
            return ga('send', 'event', 'Click Footer', $(this).text());
        });
        return $('#site-footer .widget-social-links a').click(function () {
            return ga('send', 'event', 'Click Footer', $(this).attr('title'));
        });
    });

</script>


<script type="text/javascript"> var utag_data = {}; </script>
<script type="text/javascript">
    var env = 'prod';
    if (env !== 'prod' && env !== 'qa') {
        env = 'dev';
    }
    (function (a, b, c, d) {
        window.utag_cfg_ovrd = {noview: true};
        a = './main/' + env + '/utag.js';
        b = document;
        c = 'script';
        d = b.createElement(c);
        d.src = a;
        d.type = 'text/java' + c;
        d.async = true;
        a = b.getElementsByTagName(c)[0];
        a.parentNode.insertBefore(d, a);
    })();
</script>
</body>
</html>

